Jump to content
  • Advertisement
Sign in to follow this  
carlsonc

Ignore. Didn't have all parts to the problem. fixed

This topic is 3081 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ignore. Didn't have all parts to the problem. fixed

[Edited by - carlsonc on July 7, 2010 3:57:58 AM]

Share this post


Link to post
Share on other sites
Advertisement
Your test, "if n % 6 == 0 or n % 9 == 0 or n % 20 == 0" is completely wrong: it finds multiples of one McNugget offer, not linear combinations of all three.

I would iterate through a,b,c triples in order of increasing a+b+c=k, recording the corresponding n=6a+9b+20c values, and storing a set of the impossible n values.
Given the set of n values obtained for each k, you can then a) look for 6 consecutive integers among them (termination condition) and b) remove them from the set of n values that couldn't be obtained with a smaller k (result update).


Share this post


Link to post
Share on other sites
Figured out the huge problem...and why I was so confused. I was missing an important part of the problem and I figured it out now.

P.S.
Why wouldn't "if n % 6 == 0 or n % 9 == 0 or n % 20 == 0" get all possible answers for 6, 9, and 20 assuming the program incremented n. I didn't want them separated, It just needed to be divisible by either 6, 9, or 20.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!