I am wondering if there is a way to simplify the nested loop below. The difficulty is that the iterator for each loop depends on things from the previous loops. Here is the code:
# Find the number of combinations summing to 200 using the given list of coincoin=[200,100,50,20,10,5,2,1]total=[200,0,0,0,0,0,0,0]
# total[j] is the remaining sum after using the first (j-1) types of coin
# as specified by i belowcount=0
# count the number of combinationsfor i in range(int(total[0]/coin[0])+1):total[1]=total[0]-i*coin[0]for i in range(int(total[1]/coin[1])+1):total[2]=total[1]-i*coin[1]for i in range(int(total[2]/coin[2])+1):total[3]=total[2]-i*coin[2]for i in range(int(total[3]/coin[3])+1):total[4]=total[3]-i*coin[3]for i in range(int(total[4]/coin[4])+1):total[5]=total[4]-i*coin[4]for i in range(int(total[5]/coin[5])+1):total[6]=total[5]-i*coin[5]for i in range(int(total[6]/coin[6])+1):total[7]=total[6]-i*coin[6]count+=1print count