see the code i posted above.
as I mentioned before, a fairly simple relationship can be established from 1 cent to 5 cents to 10 cents.
1 cent = 1 penny
5 cents = 5 * [solution for 1 cent] + 1 nickel
10 cents = [solution for 5 cents] * [solution for 5 cents] + 1 dime
so I think by extension:
25 cents = [solution for 10 cents] * [solution for 10 cents] * [solution for 5 cents] + 1 quarter
but perhaps, it's easier to think of it this way:
25 cents = [solution for 15 cents] * [solution for 10 cents] + 1 quarter
which *then becomes*
25 cents = [solution for 10 cents] * [solution for 10 cents] * [solution for 5 cents] + 1 quarter
so in theory, the only thing you need in your base case... is to add the additional coin. the rest is just a matter of doing an i-j for loop to combine two subcases you get from subtracting the largest possible coin.
second attempt:
Code
def change(n):
ret = []
if (n < 5):
return [pennies * n]
if (n > 25)
for (x in change(n-25)):
ret.append(x+ 1 quarter)
for (y in change(25)):
ret.append(x+y)
return ret
if (n > 10):
for (x in change(n-10)):
ret.append(x + 1 dime)
for (y in change (10)):
ret.append(x+y)
return ret
if (n > 5):
for (x in change(n-5)):
ret.append(x + 1 nickel)
for(y in change(5)):
ret.append(x+y)
return ret
or something like that.
Just try it out on paper...
Solution for 10 * Solution for 10 doesnt give out solution of 20.
using your formulae : 4x4 + 1 = 17... which is 8 too much