English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2007-12-21 20:53:01 · 6 answers · asked by Anonymous in Science & Mathematics Mathematics

Hi,thanks for answers to date. More info: the 4 numbers will always be single figures only, and may include zero, but will be produced as the result of previous calculation, and therefore cannot be easily manipulated later in excel e.g. ascending/descending. Ideally the sum of the top two numbers needs to be one automatic calculation, not an observation.

2007-12-21 22:04:49 · update #1

6 answers

If you have a sorting algorithm:
STEP 1: sort from highest to lowest
STEP 2: add element 1 and element 2

If you don't have a sorting algorithm, use if statements:
STEP 1a: if (element 1 - element 2) is negative it means element 2 is larger, otherwise element 1 is larger.
STEP 1b: call the larger element number 5
STEP 1c: if (element 5 - element 3) is negative.. etc.
STEP 2: repeat to find your second largest element.
STEP 3: add them together.

2007-12-28 22:54:56 · answer #1 · answered by Valithor 4 · 0 0

METHOD 1:
Sort them from highest to lowest and add the first two terms.

METHOD 2:
Sort them from lowest to highest and add the last two terms.

METHOD 3:
Add up all the values and subtract to 2 lowest values.

METHOD 4:
Remember 2 numbers at a time. As you look at each subsequent numbe, see if it is bigger than the smallest number you have remembered so far. If so, throw that out and remember the new number. Continue until you have looked at all 4 numbers.

Edit:
You added a note saying you were looking for a way to do this in Excel. Well certainly you could create a custom VBA macro that could implement any of the methods I mentioned before, but actually there are a couple Excel functions you can use already:

Let's say your numbers were in cells A1 through A4, then you could write the following formula:
=MAX(A1:A4)+LARGE(A1:A4,2)

This adds the largest number in the range to the 2nd largest number in the range.

2007-12-22 05:07:02 · answer #2 · answered by Puzzling 7 · 0 0

1,2,3,4

1+1=2
1+2=3
1+3=4
1+4=5

2+2=4
2+3=5
2+4=6

3+3=6
3+4=7

4+4=8


4+4=8
has the highest value

2007-12-22 05:03:19 · answer #3 · answered by Melissa 6 · 0 0

Psuedocode to do this would look like this:

x(1), x(2), x(3), x(4) are the four numbers... think of 1..4 as subscripts.

Then there are two approaches: carry out all multiplications and pick out maximum (simplest to understand/write), or find two largest numbers (quicker?) and then multiply.


% Take x(1) to be largest arbitrarily.
LARGEST = x(1).


For i = 1 to 4
......if x(i) > LARGEST then
...............set LARGEST = x(i) and set i_LARGEST = i
end

SLARGEST = x(1).
For i = 1 to 4
.......if x(i) > SLARGEST AND i != i_LARGEST then
................set SLARGEST = x(i)
end

product = LARGEST + SLARGEST
(The periods are there just to get indentation right. And != means "not equal to" in computer-speak.)

I think this will work for you, and is O(N).

Is this kind of stuff helpful?

2007-12-22 05:12:55 · answer #4 · answered by nicholasm40 3 · 1 0

Give me those four numbers, observing them I shall tell you, if you can't see.
No need of adding them or any two in turn. Just arrange them in ascending order, the last two are the numbers you want.
If you can add any two, you know them numerically and then only observation will do.

2007-12-22 05:51:01 · answer #5 · answered by sv 7 · 0 1

add two different numbers at each time and find out which one pair has the highest sum....

2007-12-22 04:56:09 · answer #6 · answered by jamesyoy02 6 · 0 0

fedest.com, questions and answers