Numbers juggling.
Date: 12/28/04
(Algorithms) Keywords: no keywords
Hi all!
Does anyone know optimal algorithm to find minimal set of numbers which will sum up to some value?
Example:
Target value is 5, we have set of numbers: 1, 1, 2, 3, 4.
So algorithm should pick 1+4 or 2+3, but not, say, 1+1+3.
Numbers in set can be of any value, quantity if then is not limited.
If you have code snipped - that would be great as well! Language does not matter (as long it is not something like Cobol). :-)
Source: http://www.livejournal.com/community/algorithms/42071.html