View Single Post
  #7   Report Post  
Bill Martin
 
Posts: n/a
Default

What you said about the amount of numbers was also my concern. Of course
nobody in a good state of mind would like his PC to work day and night for a
week to solve something like that.


(I was thinking more in terms of 100 years or more)


But it is a challenge (in my point of view) to make a program that would
do the job for, let's say, 20 or 30 numbers.


Well, 20 numbers have potentially 1 million solutions to search. 30 numbers
have about a billion. Either way it's more than you want to do with Excel,
and would instead want to use some much faster executing compiled programming
language like Fortran or C or some such.

The basic approach is simple if you want to pursue it as a challenge. You
sort of need to follow Ken Wright's approach. For 20 numbers you also create
a 20 bit binary number, starting from 0. Add up each of your numbers that
have a corresponding "1" in the binary number until the sum exceeds your
target sum, or you run out of numbers without reaching the target. Then you
iterate your binary number by 1 and do the whole thing over -- and over, and
over.

With some clever programming you could speed this up significantly for 20
numbers, but you'd still never be clever enough to do it exhaustively for 50
or 100 numbers. Ignoring of course pathological cases like where all the
numbers are somehow related, or all zero or some such where there could be
algorithms other than exhaustive searching.

Bill -- (Remove KILLSPAM from my address to use it)