Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 9 Online
OpenStudy (anonymous):

i was doing pset2 and can not figure out a logic for problem 3: Write an iterative program that finds the largest number of McNuggets that cannot be bought in exact quantity. Your program should print the answer in the following format (where the correct number is provided in place of ): “Largest number of McNuggets that cannot be bought in exact quantity: ”? i did the first 2 problem using 3 for loops (one for each variable)?

OpenStudy (anonymous):

You should be able to modify your solution to previous parts in part 3. We know that once 6 solutions in a row are found, every number higher will be able to be purchased in exact quantity. This question wants you to figure out what the largest number of nuggets is that has no solution. Essentially you will run the same test as the previous subset but the focus is on numbers that cannot be purchased exactly. You can create a variable that will keep track of numbers with no solutions. Then you want it to print the highest number for which there are no solutions. Thus, once you find 6 solutions in a row, you know the last number for which there was no solution, is the correct answer and your test can stop running.

OpenStudy (anonymous):

seems like a nice idea ...trouble is i had the same idea but cant figure how to write it into code

OpenStudy (anonymous):

and if i try something it just stucks into infinite loop

OpenStudy (anonymous):

If you really get stuck, post the code in dpaste or similar, and we can have a look and see where you are going wrong.

OpenStudy (anonymous):

so, what do you have to do that is different in this problem compared to the others in this pset?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!