Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. from typing import List
  2.  
  3. def count_change(money: int, coins: List[int]):
  4. if money == 0:
  5. return 1
  6. # Amount > 0
  7. if len(coins) == 0:
  8. return 0
  9. # Amount > 0, 1+ coins
  10. coin = coins[0]
  11. if money < coin:
  12. return count_change(money, coins[1:])
  13. else:
  14. return count_change(money, coins[1:]) + count_change(money - coins[0], coins)
  15.  
  16. print(count_change(5,[5,2,1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement