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

Is the answer to problem 3 of problem set 2, 43?

OpenStudy (damon):

Sounds reasonable. I'm working on that one too right now, but haven't got it. Could you please post your program?

OpenStudy (anonymous):

yeah , 43 is my solution too . I think it's the right answer !

OpenStudy (anonymous):

Thanks Alwahsh. Damon, I would post the code, but I've chopped it up trying to solve the next problem and didn't save the original. I made a set of multiples of 6, another of multiples of 9 and then multiples of 20 (up to 50 since we know the theorem applies above 50). I added the sets(lists) together, inclusive of the originals. Then I sorted the set from least to greatest. Then I sifted out the repeated numbers. The result was a list of solutions up to 50. 44 through 48 (x, x+1, x+2, etc.) were all solutions, so I knew that I could stop at 43.

OpenStudy (anonymous):

yes I think it was 43.

OpenStudy (anonymous):

Joe, I pretty much used the same concept and used a variable 'consecutive' to check if you had a certain amount of solutions in a row (which in this case is the minimum of the packsizes at 6) my code is a little messy, and I had to write a 'dotproduct' function because it was the first way I could come up with (solve ax + by + cz = n). I'm pretty sure everyone else have much more elegant solutions. My code is below http://codepad.org/WPFEYmV0

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!