Created
May 5, 2015 18:54
-
-
Save fabian57/7a13a6610d9b75ea2a41 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
TARGET = 200 | |
coins = (1, 2, 5, 10, 20, 50, 100, 200) | |
def coin_search(coins): | |
if min(coins) == TARGET: | |
return 1 | |
elif min(coins) > TARGET: | |
return 0 | |
else: | |
return coin_search(TARGET-min(coins), coins) + coin_search(TARGET, coins[1:]) | |
print coin_search(coins) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment