Given a set of integers, is there an easy way to find the highest combination that is less than or equal to a maximum?
For example given (3, 7, 5) and a target of 13 we'd want 7+3+3=13 (though 5+5+3 is also correct, we only need one solution). If we had (4, 6, 12) and a target of 7 the maximum would be 6.
I can't seem to work out a "nice" algorithm to handle this, is there anything obvious I'm missing?
First Glance (Score:1)
No perfect way to solve it. Lots of imperfect solutions abound, and there's probably one that suits your needs somewhere out there...
------------------------------
You are what you think.
Re:First Glance (Score:2)
Re:First Glance (Score:1)
Indeed, it doesn't. Actually it makes it harder.
Re:First Glance (Score:1)
------------------------------
You are what you think.