RE: Looking for help with a complex algorithm

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

 



[snip]
it is a special case of the knapsack problem - the "subset sum" problem.

You'll need to be aware that it's of exponential complexity. So make
sure your lists of possible values don't get big. Anyway, here's my
answer:
[/snip]

Thanks to all who responded, some very cool solutions and some more
insight to the problem ("subset sum" as Robin mentions above) has given
me the wheels that I need to solve the issue at hand.

I wanted to point out something here while we are discussing this; there
are tons of algorithms out there for solutions to problems such as these
and we sometimes as developers (instead of mathematicians or logicians)
fail to look for these when trying to solve the problem. My problem in
this case was that I knew that there was an algorithm I just could not
recall what it was. I managed to get close (knapsack problem) and the
solutions provided by several of you were elegant and work well.

There is another ongoing thread about OOP in PHP4 that has approached
holy war status. I fear that some are overlooking solutions to problems
that already have been solved. Things such as interfaces and design
patterns exist because they are solutions to problems just as
identifying the right problem here leads to a solution (the algorithm).

-- 
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