So this is a two-part problem involving coins. The first part involves summing the coin counts of amounts 1-99 cents (for example, it takes 1 coin to get to 1 cent, 2 coins to get to 2 cents, etc. and adding the total amount of coins it takes to get to each value). This can be represented by the following code (feel free to make suggestions/improvements):
def findbest(origarray, denom):
current = origarray
i = 1
while(i < size):
if(i in denom):
current[i] = 1
coinlist[i] = [i]
else:
k = 1
while(k < 1 + (i/2)):
c = current[k] + current[i-k]
if(c < current[i]):
current[i] = c
coinlist[i] = coinlist[k] + coinlist[i-k]
k+=1
print i, current[i], coinlist[i]
i+=1
return current
size = 100
coinlist = [[]]
origarray = [0]
i = 1
while(i < size):
origarray.append(100)
coinlist.append([])
i += 1
denom = [1,5,10,25,50]
x = findbest(origarray, denom)
total=0
for value in findbest(origarray,denom):
total += value
print total
print "\n\n\n"
print x
The second part of the problem is finding the ideal three denominations (don't have to be real denominations, but one has to be 1) that will yield the lowest total of all coin counts. This is where it gets tricky for me. I know I have to write something that will brute-force the denomination values until it finds the optimal three (which I know are [1,12,19], I just can't get to that point), but I'm not sure how to go about doing that. Does anyone have an idea of how to do this?