Files
Algorithmik-II/Uebung-01/decomposition.py
Jan-Niclas Loosen 90ce78f17d Dice simulator
2025-10-24 20:58:31 +02:00

14 lines
260 B
Python

import math
def decomp(x: int, base: list[int]) -> dict[int, int]:
base = sorted(base, reverse=True)
coef = {}
for b in base:
c = math.floor(x / b)
coef[b] = c
x -= b * c
return coef
print(decomp(25, [1, 5, 10, 25]))