Skip to content

Instantly share code, notes, and snippets.

@jbochi
Created November 21, 2012 23:30
Show Gist options
  • Save jbochi/4128535 to your computer and use it in GitHub Desktop.
Save jbochi/4128535 to your computer and use it in GitHub Desktop.
Dá troco
def change(n, coins):
if n == 0:
return 1
elif n < 0 or len(coins) == 0:
return 0
else:
return change(n, coins[1:]) + change(n - coins[0], coins)
print change(10, [10, 5, 2, 1])
print change(3, [1, 2, .5, 5, 10])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment