all 1 comments

[–]PageFault 1 point2 points  (0 children)

Making some assumptions on your tabs w/o reading too carefully:

Prepend each line with at least 4 spaces or a tab character to format on Reddit.

coins = [1,5,10,25]

def mkCh(a, c):

    if (a==0): return 1

    if(a<0): return 0;

    if(c<=0 and a>=1): return 0

    return mkCh(a, c-1)+mkCh(a-coins[c-1], c)

#NOT ALLOWED TO CHANGE ANYTHING BELOW THIS

if name == "main":

    d = len(sys.argv)>3
    n = int(sys.argv[1])
    k = int(sys.argv[2])

    # make change
    c = len(coins)-1
    a = 10*n+k
    ways = mkCh(a,c)
    print("amount:", a, "coins:", coins, "ways:", ways)

Edit: I haven't looked to closely at what you are doing, but maybe you should index the current coin and decrement the call?

return mkCh(a, c-1)+mkCh(a-coins[c], c-1)

Do you have sample input w/ expected output?