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

Does anyone have a completed example of PS2, question 3 I could look at?

OpenStudy (anonymous):

what are you having a problem with?

OpenStudy (anonymous):

Here is my code: def solve3(numNuggets): for numTwenties in range(0, numNuggets/20 + 1): for numNines in range(0, (numNuggets - numTwenties*20)/9 + 1): numSixes = (numNuggets - numTwenties*20 - numNines*9)/6 totNuggets = 20*numTwenties + 9*numNines + 6*numSixes while totNuggets == numNuggets: numNuggets = solve3(numNuggets - 1) return numNuggets When I make numNuggets between 44-50 , I get 43, which I believe is the right answer. But when I put in a value like 70, I get a crazy answer like 17, and I can't figure out why...

OpenStudy (anonymous):

Any ideas?

OpenStudy (anonymous):

use dpaste.com or something similar to post your code have you written down on paper what you are trying to do? having a recursive call within a while statement seems like a funny thing to do print statements help when trying to debug your code - they let you see what is actually happening and you can see if it is what you meant to happen. i added one to yours, hope it helps: http://dpaste.com/604576/

OpenStudy (anonymous):

Here is what I have: http://dpaste.com/605624/

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!
Latest Questions
kaelynw: art igg
2 hours ago 6 Replies 1 Medal
XShawtyX: Art
14 hours ago 6 Replies 0 Medals
Nina001: teach me how to draw or just tell me the basics
16 hours ago 2 Replies 1 Medal
XShawtyX: We doing another drawing gimme ideas to add to this
17 hours ago 9 Replies 1 Medal
RAVEN69: What is x 3+y 3+z 3=k
22 hours ago 20 Replies 1 Medal
cinna: Who is good with photo editing? Dm me pls
1 day ago 2 Replies 0 Medals
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!