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,
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
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
please reply when you read my comment
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.
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
btw are you a professor or something bwCA?cause you do seem to know your stuff and you speak like one..:)
nope, i'm just an old guy that hangs around here cause it helps me learn
n0el_lobo would you mind posting your code?
Join our real-time social learning platform and learn together with your friends!