anonymous
  • anonymous
I'm doing PS2 problem 4. My program gives me a list of values which can't be obtained from boxes of 6,9,and 20 Mcnuggets. How do I make my program only print the last (i.e. the highest) value? http://codepad.org/08nyijrk
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
put all the can't-be-boughts in a list and print the last one http://pastebin.com/32LkCpsg everytime a number can't be bought, save it and keep track of consecutive can-be-boughts - when you get to 6, the last number you saved as cannot be bought should be the highest
anonymous
  • anonymous
Attached is my answer to Problem Set 2 (Part I) Hope this helps.
1 Attachment
anonymous
  • anonymous
pelikan: This is my solution to Problem Set 2 (Part IV). As bwCA explained you need to keep the highest value in bestSoFar. In my code I inserted a check so that the bestSoFar is only replaced if a larger number is discovered. I'm not sure whether this was necessary. Hope this helps.
1 Attachment

Looking for something else?

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

More answers

anonymous
  • anonymous
I have changed my code. for some reason i get a time out error for 200 McNuggets but if I change it to approx 50 it works. http://codepad.org/IsJxFqZy . Thanks for sending your code I'm going to take a look at it now
anonymous
  • anonymous
I changed the code again and it works now. http://codepad.org/8SucYGFW . Thanks a lot for the advice!!

Looking for something else?

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