Find minimum number of coins that make a given value: Difference between revisions

m
use divmod
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:
coins, remaining = sorted(denominations, reverse=True), total
for n in range(len(coins)):
coinsused, remaining = divmod(remaining //, coins[n])
if coinsused > 0:
remaining -= coinsused * coins[n]
print(" ", coinsused, "*", coins[n])
 
4,107

edits