Skip to content

Instantly share code, notes, and snippets.

@fabian57
Created May 5, 2015 18:54
Show Gist options
  • Save fabian57/7a13a6610d9b75ea2a41 to your computer and use it in GitHub Desktop.
Save fabian57/7a13a6610d9b75ea2a41 to your computer and use it in GitHub Desktop.
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