tags:

views:

185

answers:

2
A: 

I think that you are on the wrong track with using mod.

It seems to me that this is a variation to a "greedy algorithm" problem, normaly associated with working out efficient change with coins in homework questions, but I think this seems to be a variant of it.

Wikipedia has a page on it, and I am sure googling greedy algorithm will help you out.

Tim Jarvis
+4  A: 

The hard part isn't writing the code. The hard part is figuring out what the algorithm is that solves this problem. Once you have the algorithm solid, turning it into code will be straightforward.

What are your thoughts on the algorithm? Start with some contrived examples. For instance, suppose you are given 1/9/2. A solution to that is IR. How would you, as a human, come up with that solution? Can you describe a method whereby you, a human, could always come up with the answer?

Eric Lippert