Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- coins = {5: 0, 2: 0, 1: 0}
- money = 28
- sum = 0
- while sum != money:
- matching_coins = [c for c in coins if c + sum <= money]
- if matching_coins:
- coin = max(matching_coins)
- coins[coin] += 1
- sum += coin
- else:
- print("No solution")
- print(coins)
Add Comment
Please, Sign In to add comment