anonymous
  • anonymous
What do you think about this code for problem 2?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
nugget_pacs=(input("Package Size 1 "),input("Package Size 2 "),input("Package Size 3 ")) # tuople contains nugget package sizes tracker=[] # list which will hold possible combinations not_tracker=[] # list to hold combinations not possible for n in range(1,150): # range of numbers to consider as candidates can_buy=0 for a in range(0,(n/nugget_pacs[0])+1): for b in range(0,(n/nugget_pacs[1])+1): for c in range(0,(n/nugget_pacs[2])+1): if nugget_pacs[0]*a+nugget_pacs[1]*b+nugget_pacs[2]*c ==n: can_buy=1 tracker.append(n) # adds the possible combo to list if tracker.count(n)>1: # if statement to remove repeats tracker.remove(n) if can_buy==0: not_tracker.append(n) # adds value of n not possible to list print 'Possible Combinations are' ,tracker print 'These Combinations are not possible' , not_tracker
anonymous
  • anonymous
does it run? I do not get where you are taking nugget_pacs from?
anonymous
  • anonymous
woops mom

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
looks alright...if it runs an spits out good results it should be fine
anonymous
  • anonymous
# chickennuggets.py # dio equations ### ### template of code for Problem 4 of Problem Set 2, Fall 2008 ### bestSoFar = 0 # variable that keeps track of largest number # of McNuggets that cannot be bought in exact quantity pack = (6,9,20) # variable that contains package sizes lim=55 lima=lim/6 limb=lim/9 limc=lim/20 solution=False list=[] for n in range(1, lim+1): # only search for solutions up to size 150 ## complete code here to find largest size that cannot be bought ## when done, your answer should be bound to bestSoFar solution=False for a in range(lima+1): for b in range(limb+1): for c in range(limc+1): trialn=pack[0]*a+pack[1]*b+pack[2]*c if trialn==n: solution=True break if solution: break if solution: break if solution: savenws=n list.append(n) print n, "has a solution, being", a, b, c if len(list)==6: break else: print n, "does not have a solution" saven=n list=[] print saven, "largest without solution, given package size", pack But I already incorporated that sequence of six from the next assignment...but apart from that it is similar in logic...
anonymous
  • anonymous
also I did not save all possible combos...I took the first best and left
anonymous
  • anonymous
nugget_pacs is a tuople containing the size of the different packages which is taken in as input from the user. It then callc the specific package size by calling its index

Looking for something else?

Not the answer you are looking for? Search for more explanations.