Created
October 8, 2014 14:23
-
-
Save scdekov/6a6321cf53097ca3bd9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_coins(sum): | |
coins = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0} | |
list_of_coins = [100, 50, 20, 10, 5, 2, 1] | |
sum = sum * 100 | |
while sum > 0: | |
for coin in list_of_coins: | |
if coin <= sum: | |
coins[coin] = coins[coin] + 1 | |
sum = sum - coin | |
break | |
return coins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment