im trying to find the number of combinations to find a sum with several coins.
my original function works,but i dont know how to put the memoization in/
please help me!
update:
i get a list of coins[1,2,3,5] and a sum (10)
and need to count all the combination possibilities to get to that exact sum with unlimited supply of each coin
We are not permitted to use loops.....
examples:
>>> find_changes_mem(100,[1,2,5,10])
2156
my original function works,but i dont know how to put the memoization in/
please help me!
update:
i get a list of coins[1,2,3,5] and a sum (10)
and need to count all the combination possibilities to get to that exact sum with unlimited supply of each coin

def find_changes_mem(n, lst, memo=None): ##if memo==None: ## memo={} if n < 0: return 0 if n == 0: return 1 if not lst: return 0 return find_changes_mem(n - lst[0], lst) + find_changes_mem(n, lst[1:]) find_changes_mem(4,[1,2,5,10])
We are not permitted to use loops.....
examples:
>>> find_changes_mem(100,[1,2,5,10])
2156