@kd1510 the reasoning behind wanting to know the maximum number of each size is so you know what numbers each of your for loops should traverse.
totals = (50, 51, 52, 53, 54, 55)
for total in totals:
# find the max a where b and c are zero
maxA = total/6
# find the max b where a and c are zero
maxB = total/9
# find the max c where a and b are zero
maxC = total/20
# preset a variable to indicate if we were able to solve
solutionPossible = False
# Loop through all possible combinations
for i in range(0, maxA):
for j in range(0, maxB):
for k in range(0, maxC):
if (i*6 + j*9 + k*20 == total):
print str(total) + " solved: a=" + str(i) +" b=" + str(j) + " c=" + str(k)
solutionPossible = True
break
if (solutionPossible == False):
print str(total) + " couldn't be solved"
##########################################
So what you want to do (for this brute force method that is), is:
Find the maximum number of each of the packets there could possibly be (because you don't want or need to loop more than that).
Then, loop through all the possibilities. You want to check from zero (because there might have been zero of that packet) all the way up to the max, for every combination.