Robin,
you made it harder for me specially with wikipedia artical :) (I told
you I'm bad with writing code from English paragraph)
and no it's not a homework (btw: do they allow php in school ?, I
remember we use basic :) )

anyway I will try to write the code and I will let you guys know (in
the mean time if someone can help me in anyway I really appreciate it)


On 9/25/06, Robert Cummings <[EMAIL PROTECTED]> wrote:
On Mon, 2006-09-25 at 16:42 +0100, Robin Vickery wrote:
> On 24/09/06, Ahmad Al-Twaijiry <[EMAIL PROTECTED]> 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?
>
> http://en.wikipedia.org/wiki/Subset_sum_problem

Cool, I didn't know it had a specific name, all I could think of was
that it sounded a lot like the knapsack problem. The Wikipedia article
indicates it's a special case of the knapsack problem.

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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




--

Ahmad Fahad AlTwaijiry

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

Reply via email to