Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from typing import List
- def count_change(money: int, coins: List[int]):
- if money == 0:
- return 1
- # Amount > 0
- if len(coins) == 0:
- return 0
- # Amount > 0, 1+ coins
- coin = coins[0]
- if money < coin:
- return count_change(money, coins[1:])
- else:
- return count_change(money, coins[1:]) + count_change(money - coins[0], coins)
- print(count_change(5,[5,2,1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement