Dice simulator
This commit is contained in:
14
Uebung-01/decomposition.py
Normal file
14
Uebung-01/decomposition.py
Normal file
@@ -0,0 +1,14 @@
|
||||
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]))
|
||||
Reference in New Issue
Block a user