I have an array of numbers (a column in excel). I calculated the half of the set's total and now I need the minimum number of set's values that the sum of them would be greater or equal to the half of the total.
Example:
The set: 5, 5, 3, 3, 2, 1, 1, 1, 1
Half of the total is: 11
The least amount of set values that need to be added to get 11 is 3
What is the formula to get '3'?
It's probably something basic but I have not used calculus in a bit hence may have forgotten just forgotten it.
Normally I would use a simple while loop with a sort but I am in excel so I was wondering is there a more elegant solution.
P.S. I have the values sorted in descending order to make things easier.
EDIT: Example
Let the values $5, 5, 3, 3, 2, 1, 1, 1, 1$ be input in the cells $A1$ to $A9$
In cell $A10$ you calculate the half of the sum: =sum(A1:A9)/2
In the cells $B1$ to $B9$ you input the values $1$ to $9$
In cell $C1$ you input the following formula: =if(sum(\$A\$1:A1)=>A10, 1,0)
You copy (drag and drop) the formula of $C1$ into cell $C2$ to $C9$
In cell $D1$ you input the formula: =If(C1=1,1,0)
In cell $D2$ your insert the formula =If(And(C1=0,C2=1),1,0)
You copy the formula of $D2$ into cells $D3$ to $D9$
In the cell $E1$ you insert the formula =D1*B1
Finally you copy the formula of $E1$ into cells $E2$ to $E9$