## Probably should've defined variables first but first I let a user define my tuple. I'd prefer if there was a good way that they could just type ## something like "6,9,20" but quick googling didn't help me with that. Guess I should find and read that book. firstBox=int(raw_input("How many nuggets in the first box? ")) secondBox=int(raw_input("How many nuggets in the second box? ")) lastBox=int(raw_input("How many nuggets in the last box? ")) box=(firstBox,secondBox,lastBox) ##Figuring out how many consecutive possibles I'm gonna need smallestBox=box[0] if box[1]<smallestBox: smallestBox=box[1] if box[2]<smallestBox: smallestBox=box[2] ##Defining all the stuff I'm gonna need later a,b,c=0,0,0 possibles=0 largestImpossible=0 n=0 greaterThanOneFifty=False ##This is how I did my test. If my current abc values multiplied by their box sizes gets me my n, I'm done, I move onto a new n. ##If that n is too big I stop by making possibles too big and make a boolean so I can check it out later. ##If it's less than n, I increment a. If it's greater than n, things get hairy. I set a to zero and increment b, unless a is already zero. ##If a is already zero, I set b to zero and increment c. If b was already zero, then that means there is no solution, I save it, and reset my "possibles". while possibles<=smallestBox: if (a*box[0]+b*box[1]+c*box[2])==n: n=n+1 if n>150: greaterThanOneFifty=True possibles=smallestBox+1 possibles=possibles+1 a,b,c=0,0,0 else: if (a*box[0]+b*box[1]+c*box[2])<n: a=a+1 if (a*box[0]+b*box[1]+c*box[2])>n: if a==0: if b==0: largestImpossible=n possibles=0 n=n+1 a,b,c=0,0,0 else: b=0 c=c+1 else: a=0 b=b+1 ## Here are my end conditions, if I got to too high n's I print one message, if I found a largestPossible that survived a smallestbox ## number of checks, I present it. if greaterThanOneFifty==True: print "If there's a largest amount of nuggets you can't get with packages of"+str(box[0])+","+str(box[1])+", and "+str(box[2])+", it's greater than 150." else: print "The largest amount of nuggets you can't get with packages of "+str(box[0])+", "+str(box[1])+", and "+str(box[2])+" is "+str(largestImpossible)+"."