A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
Ps2 q3 help,
i was struggling with how to work this one out so i looked at how others had done it, unfortunately it has not helped.
I am not sure how to get it to try all other combanations.
My code is at the top and the sample i worked from which works is at the bottom
http://codepad.org/j6i9IFpm
anonymous
 4 years ago
Ps2 q3 help, i was struggling with how to work this one out so i looked at how others had done it, unfortunately it has not helped. I am not sure how to get it to try all other combanations. My code is at the top and the sample i worked from which works is at the bottom http://codepad.org/j6i9IFpm

This Question is Closed

maitre_kaio
 4 years ago
Best ResponseYou've already chosen the best response.0I don't understand what you're doing inside the while loops. Could you explain ?

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0I am not sure of the maths so the nested for loop at the top to work out the pack size is confusing to me. The code works out the pack size and then that is added to a list, from that i thought if i checked the last one and the one 6 before that to see if they are consecutive then the one 7th before the end was the answer. I noticed with print that there was duplicates and it was not putting them in order so i removed dups with set then ordered them again but still no joy which was when i posted. After that i ran it through the debugger and found that it does not work out them in order so i have to check from the beginning each time. I now have it working if you could explain the math or give me feedback on my code that would be very helpful. http://codepad.org/7rpqG7Fj

maitre_kaio
 4 years ago
Best ResponseYou've already chosen the best response.0OK I understand the first part of your code now. For each number of nuggets: you enumerate all the combinations of a, b, c that could potentially give you the number and you calculate how many nuggets it would really give. I must say I don't really understand the second part. Seems pretty complicated to me.

maitre_kaio
 4 years ago
Best ResponseYou've already chosen the best response.0Your program seems to produce the right results, but I must say I've never thought this problem could be solved this way. The 'standard' way is the following: 1. Write code to test if it is possible to buy a given number of nuggets 2. Enumerate through positive integers. For each, use the preceding code. If we can find 6 consecutive integers that are ok, the solution is the last non ok number
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.