Hi i'm stuck on problem set 3 problem 2 calculating the highest number of mcnuggets that don't work. We can calculate what numbers work but we can't make it say what doesn't work. Any help???
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 :)
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.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Can you provide a link to the problem?
the set of number that do work, will be equal to all the numbers, minus all the numbers that do work
Not the answer you are looking for? Search for more explanations.
It looks like you're looking at problem set 2, problem 3.
And I'm glad you posted the whole thing, thanks!
I think what you want to does is use the theorem from problem 2.
This states that if you get to \(x\) McNuggets, and then you find that all of
McNuggets are acceptable, then you can be sure that \(x\) McNuggets can be purchased from the groups of 6, 9, or 20.
Whichever last number of McNuggets that didn't work is the last number of... I repeat myself. But that's it!
Now you need to follow the algorithm listed in there.
But first, since we just found the last number of McNuggets that we can't put together with 6. 9. and 20... Do we have to keep track of it? Or is knowing \(x\) good enough?
How do you plan to keep track of what \(x\) is, or what you've tested already?
These are good concerns to have, around which you can tweak the given basic algorithm into a well-working one.
And part of the basic algorithm suggests you have to find \(a\), \(b\), and \(c\) in
where \(n\) in the number of McNuggets in question.
Being exhaustive is easy - look for all the possibilities within reason! "For" loops, maybe. Or maybe "while" loops. I'd choose "while" loops, I think. But, either way, just make sure that you develop a good stopping condition. You don't want to have the computer go up to
\(6\times 50,000,000,000+9\times 0+20\times0\)
just because it hasn't worked out.
Side note: if this wasn't exhaustive, you'd look for some other pattern. And you'd look for all the shortcuts. One that I can think of is inspired by the case above. When you look at the case of \(b=0,\ c=0\), then you're left with \(6a\). You can use \(6a\) to get to \(n\) only if \(n\) is a multiple of \(6\). A language's modulo function might check that out quickly.
In fact, you can use a similar argument when
but this is all irrelevant to your problem.
And in the case of just \(c=0\), you are left with \(6a+9b=n\), in which case \(n\) is a multiple of three.
But this is exhaustive. Sort of like using a steamroller in a bowling alley rather than using a bowling ball and mad skills.
I hope this helps! Feel free to ask questions! Take care!