finding which numbers add up to "x"
- From: Eric <Eric.Medlin@xxxxxxxxx>
- Date: 31 May 2007 13:39:18 -0700
I have a list of numbers and I need to find what numbers in the list
add up to "x". I can reuse the numbers more than once but I have to
use "n" numbers. Is there anything faster than a brute force method
with the tricks to stop some iteration early because you know the
remaining iteration will added up to be to larger than "x". This
assumes the list is in order. It would be nice to find all the
solutions and not just the first one.
Ex.
List: 25, 20, 15, 10, 5
X: 50
N: 4
Some Solutions: 25, 15, 5, 5; 20, 20, 5, 5; etc.
.
- Prev by Date: Re: problem on medians
- Previous by thread: problem on medians
- Index(es):