anonymous
  • anonymous
I'm on ps2 problem 1 and 2. I wrote some code that prompts the user to enter a range and finds the first combination of 6,9, and 20 packs that will that adds up to that. I've found that you get at least one combination from 43 on, but I don't really understand the math behind it, specifically what the theorem is asking for. Basically i understand it in practice, but not in theory. Below is a link to the code i've come up with http://codepad.org/ooVDsOzJ
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
I found the best way to understand the math is work the problem out on paper. By combining possible solutions by hand the math will reveal itself. I made a chart with three columns and just started showing how putting 6pc 9pc 20pc in different amounts would come up with a given number and how smaller values would be impossible to reach as in 1,2,3,4,5,7,8pc and how large numbers would always be possible. You will see very quickly that after 43 every number higher is possible using combinations of lesser values. Chart it out and it becomes very clear what is going on. with 6x+9y+20z=n
anonymous
  • anonymous
Will do, thank you for your response.
maitre_kaio
  • maitre_kaio
That one could be in the FAQ (if there was one :P ). Here's my answer, sorry for those who have already read it in previous questions: Basically, it is just a proof by recursion. I would explain it this way in english: Say I want to buy an arbitrary number x of nuggets and i know that it is possible to buy x, x+1,..., x+5 nuggets. I can always buy c boxes of 20 (c >=0) plus n others (0 < n < 20). Now I just need to demonstrate that can I buy n nuggets I can buy x + 6, x + 11 just by adding a box of 6. I can buy x + 12, ... x + 14 by adding a box of 9. I can buy x + 15, ..., x + 19 by adding a box of 6 and a box of 9. I can buy x + 20 by adding a box of 20. For any number greater than x + 20, I can buy a number of boxes containing 20 nuggets, and go back to the previous demonstration. So I can buy any number of nuggets greater than x. Maybe not the more elegant proof, but I think it's very visual.

Looking for something else?

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

More answers

anonymous
  • anonymous
Once you have six consecutive answers, you know you can get the rest because 6 is the smallest unit of nuggets.

Looking for something else?

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