Moved solutions till 35 to Python.
This commit is contained in:
23
python/e031.py
Normal file
23
python/e031.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user