Find minimum number of coins that make a given value: Difference between revisions
Content added Content deleted
m (added a requirement to this (draft) task to show the results here on this page, added whitespace and verbiage.) |
m (use divmod) |
||
Line 153: | Line 153: | ||
coins, remaining = sorted(denominations, reverse=True), total |
coins, remaining = sorted(denominations, reverse=True), total |
||
for n in range(len(coins)): |
for n in range(len(coins)): |
||
coinsused = remaining |
coinsused, remaining = divmod(remaining, coins[n]) |
||
if coinsused > 0: |
if coinsused > 0: |
||
remaining -= coinsused * coins[n] |
|||
print(" ", coinsused, "*", coins[n]) |
print(" ", coinsused, "*", coins[n]) |
||