anonymous
  • anonymous
Will anybody review my problem set 2 for correctness? capture = () x = input("Package size 1: ") y = input("Package size 2: ") z = input("Package size 3: ") for n in range(1,201): can_buy = 0 for a in range(0,(n/x)+1): for b in range(0,(n/y)+1): for c in range(0,(n/z)+1): if x*a + y*b + z*c == n: can_buy = 1 print n, " can by bought: ",a,b,c if can_buy == 0: print n, " cannot be bought" capture += (n,) print "Largest number of McNuggets that cannot be bought in exact quantity: ",capture
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.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
Hey your code works but on the very last line you don't want it to print all the captures only the last so change capture to capture[-1] the negative one represents the last place in the tuple. Also your range is really high so either you can take out the print statements and it will run faster or make your range like (1,50) I already know the answer that's why I say 50 but yes normally you would need a higher range.
anonymous
  • anonymous
If you have another question on what I did or whatever feel free to ask.
anonymous
  • anonymous
Hey Onyx, thanks a lot. I'm now your fan. As for the last line, I think the [-1] got cut off by the chat box without me realizing it!

Looking for something else?

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