# Getting box sizes , skipped creating a tuple as it is not that necessary # Assumed I will get a solution smaller than 90 and arranged for loop ranges accordingly a = int(raw_input('Enter smallest box size: ')) b = int(raw_input('Enter medium box size: ')) c = int(raw_input('Enter largest box size: ')) consecutive = 0 largest = 0 condition = 1 x = c + 1 # Test value, starting with 1 more than largest box size while condition: for i in range (15): # Loop for smallest box for j in range (10): # Loop for medium box for k in range (5): # Loop for largest box test = (i * a) + (j * b) + (k * c) if consecutive == a: condition = 0 break if test == x: ## print 'You can buy ' ,x , ' nuggets.' ## print i, j, k i = j = k = 0 consecutive += 1 x += 1 test = 0 elif i == 14 and j == 9 and k == 4 and test != x: print ' You cannot buy ', x , ' nuggets.' i = j = k = 0 consecutive = 0 largest = x x += 1 test = 0 print 'Largest number you cant buy = ' , largest