Re: array_sum($result)=100

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 1:50 PM -0300 9/25/06, Martin Alterisio wrote:
2006/9/25, Robin Vickery <robinv@xxxxxxxxx>:

On 24/09/06, Ahmad Al-Twaijiry <ahmadt@xxxxxxxxx> wrote:
 Hi everyone

 I have array of numbers and I want to get out of it a list of numbers
 that if I sum them it will be 100, here is my list (for example ) :

 $list = array(10,20,10,10,30,50,33,110,381,338,20,11,200,100);


 I want the result to be :

 $result = array( 10,20,10,10,50);

 as you can see in the array $result , if we array_sum($result) the
 result will be 100.

 is they any algorithm to do this ?

Ah, the Subset Sum Problem - this isn't school homework by any chance?


You're surely mistaken, there are many practical uses of the subset sum
problem in website development, like.... errr... shipping optimization!

Don't forget real world problems like when my wife gives me $100, a shopping list, and says bring back as many items as you can.

Or when I take all 10 grand-kids to McDonald's and try to buy each kid as much as I can with $20 -- my vector calculus classes in grad school didn't prepare me for that high level math.

:-)

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux