euler/python/e031.py

24 lines
501 B
Python
Raw Normal View History

2019-07-16 18:51:07 +02:00
def count_change(change, coins):
from math import ceil
count = 0
coin, coins = coins[0], coins[1:]
if change % coin == 0:
count += 1
if not coins:
return count
for i in range(ceil(change / coin)):
count += count_change(change - i * coin, coins)
return count
def euler_031():
return count_change(200, [200, 100, 50, 20, 10, 5, 2, 1])
if __name__ == "__main__":
print("e031.py: {}".format(euler_031()))
assert(euler_031() == 73682)