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

My McNuggets code has no bugs and runs, but it always print 'No solution,' even if i choose a number that I know has a solution. Any help?

OpenStudy (anonymous):

paste your code at dpaste.com then post the link here

OpenStudy (anonymous):

Here it is. http://dpaste.com/553714/

OpenStudy (anonymous):

Have you checked your solve function ? Looks like it is returning [none,none,none] all the time.

OpenStudy (anonymous):

I guess you have to think it through a little before you actually write the code. Why don't you try it first on a paper and see what happens ? You'll notice that there's more than one solution. Do you really want your code to return only one ? Instead of trying a long range of 0 to 56, try something like 0,10), see what happens and let your code print every option at each step. Does that make sense ?

OpenStudy (anonymous):

Hey listrail22! Here I corrected your code it should work fine: http://dpaste.com/553774/ :)

OpenStudy (anonymous):

Correcting codes is nice but if you think about it, syntax is not so hard- it's the thinking that makes it hard - if you correct and let someone copy without really understanding .... have you really helped him/her ? ......... just something to think about, nothing personal of course ! :)

OpenStudy (anonymous):

I moved your print statement so you can see what is happening - I tried it with 24 which should have a couple of solutions. - is that what you expected? http://dpaste.com/553789/

OpenStudy (anonymous):

The syntax was fine....it was a semantic error. So once he/she noticed the differences he/she would realize what the new code actully means. Everybody comes here to learn so nobody just copies code to submit their assignments on time(because that would be pointless). I am sorry though!

OpenStudy (anonymous):

Wow!!!! Thank you everyone who replied. Didn't expect that. All of you helped a lot. I'll be sure to post the next questions i have!

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!
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!