Good ideas and conversation. No ads, no tracking. Login or Take a Tour!
Sure, why not? It's still tree recursion after all. You just have to use an extra procedure that takes the change amount and how many coin values you have. e.g. For the UK coin values are 1, 2, 5, 10, 20, 50, 100 and 200 so there are 8 coin values. So instead of you'd use cc(amount, num_coins) and you memoize cc with indexes of amount and num_coins But I wonder if that would be as effective in this case as for Fibonacci.
count_change(amount)
count_change(amount)