Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to .....

1,325 views
Skip to first unread message

S S S S S

unread,
Dec 18, 2003, 5:27:59 AM12/18/03
to
I've a set of numbers and want to find which two numbers in the set can be
added up to a specified number. For example, the data set is {2,4,5,6,9,13}
and I want to know which two numbers will be added up to 8. The system
should tell me they are 2 and 6. Thanks!

SL


Peo Sjoblom

unread,
Dec 18, 2003, 7:09:34 AM12/18/03
to
One way but you need the solver add-in installed (it comes with
excel/office,check under tools>add-ins)
put the data set in let's say A2:A8, in B2:B8 put a set of ones {1,1,1 etc}
in the adjacent cells
in C2 put 8, in D2 put

=SUMPRODUCT(A2:A7,B2:B7)

select D2 and do tools>solver, set target cell $D$2 (should come up
automatically if selected)

Equal to a Value of 8, by changing cells $B$2:$B$7, click add under Subject
to the constraints of:
in Cell reference put

$B$2:$B$7

from dropdown select Bin, click OK and click Solve, Keep solver solution
and look at the table

2 1
4 0
5 0
6 1
9 0
13 0


there you can see that 4 ones have been replaced by zeros and the adjacent
cells to the 2 ones
total 8

--

Regards,

Peo Sjoblom


"S S S S S" <sim...@i611.com> wrote in message
news:ugHIGIVx...@TK2MSFTNGP11.phx.gbl...

0 new messages