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

Hi all - is anyone currently working on Assignment 1: McDiophantine: Selling McNuggets? I am working on it and would like to see if anyone has any input on how they would approach this (all parts). Thanks,

OpenStudy (anonymous):

sometimes it helps to write in just words what you think you need to do to solve a problem - then look at it and figure out how to turn it into a problem. like for any given number is there a combination of 6, 9, 20 packs that equal that number generate combinations of 6, 9, 20 packs and see if they add up to a certain number ask how many nuggets are required run through all the combinations of 6, 9, 20 packs till you find a combination that works. did you read the readings suggested for the lectures that this problemset covers?? http://pastebin.com/qbmLvVuQ

OpenStudy (anonymous):

i just finished writing the program. But it doesn't seem to work for 52. i can't find the combination for 52 manually either. though it works perfectly for the rest of the numbers above 50

OpenStudy (anonymous):

please reply when you read my comment

OpenStudy (anonymous):

well 52 could be a combination of 2 sixes and 2 twenties. put a print statement in where you make your combinations and print the number of 6's, 9's and 20's - that might help you see where it is going wrong. printing variables, results of tests, results of calcs ..... is a good debugging tool. post your code using a code pasting site if you want.

OpenStudy (anonymous):

thanks man.though i figured the problem. i wasn't using exhaustive enumeraion even though thats what we are told to. waswrttin more efficient code. it works great n eve till numbes i millionss...hehe

OpenStudy (anonymous):

btw are you a professor or something bwCA?cause you do seem to know your stuff and you speak like one..:)

OpenStudy (anonymous):

nope, i'm just an old guy that hangs around here cause it helps me learn

OpenStudy (anonymous):

n0el_lobo would you mind posting your code?

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!