Last active
August 29, 2015 14:20
-
-
Save neale/c68e5b7e7ff86be81085 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
def changeslow(coins, amounts, highest, sum_coins, goal, store): | |
if sum_coins == goal: | |
store == show(coins, amounts, store) | |
return | |
if sum_coins > goal: | |
return | |
for value in amounts: | |
if value >= highest: | |
copy = coins[:] | |
copy.append(value) | |
change(copy, amounts, value, sum_coins + value, goal, store) | |
sum_store = reduce((lambda x, y: x+y), min(store)) | |
return (min(store), sum_store) | |
def show(coins, amounts, store): | |
temp = [] | |
for amount in amounts: | |
count = coins.count(amount) | |
temp.append(count) | |
store.append(temp) | |
return store | |
coins = [] | |
amounts = [1, 5, 10, 25, 50] | |
store = [] | |
print changeslow(coins, amounts, 0, 0, 10, store) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment