RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Jay Blanchard
[snip] If the OP wants any single valid set, then this seems to work. If he wants all valid sets, no joy. I added a 10.00 and a 0.22 to the $values array and varied the position of the 10.00 (before and after 3.76) and it seems to pull the first set where the first member in the $values array is a

RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Instruct ICC
ists.php.net > Subject: Re: [PHP] Looking for help with a complex algorithm > > Jay Blanchard wrote: > > [snip] > > what is it suppose to return if it cannot find records that the exact > > total do not match the total > > you are looking for? should it return not

RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 07:00 -0500, Jay Blanchard wrote: > > 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

RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Jay Blanchard
[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 m

Re: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Robin Vickery
On 09/10/2007, Jay Blanchard <[EMAIL PROTECTED]> wrote: > Good afternoon gurus and guru-ettes! > > I am searching for an algorithm that will take a list of monetary values > and determine which of these values totals a value supplied to the > widget. > > 1. I supply a value to the application and g

RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Per Jessen
Robert Cummings wrote: > On Tue, 2007-10-09 at 15:28 -0500, Jay Blanchard wrote: >> [snip] >> This *IS* the knapsack problem. Just because you specify date ranges >> to get your values and the value isn't a knapsack doesn't change the >> fact that it is the same problem :) I remember having fun wi

Re: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Jim Lucas
Jay Blanchard wrote: [snip] what is it suppose to return if it cannot find records that the exact total do not match the total you are looking for? should it return nothing? [/snip] Correct. It should say that there are no records that generate a match. Ok, so based off what you were aski

RE: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Jay Blanchard
[snip] what is it suppose to return if it cannot find records that the exact total do not match the total you are looking for? should it return nothing? [/snip] Correct. It should say that there are no records that generate a match. -- PHP General Mailing List (http://www.php.net/) To unsubscr

Re: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Jim Lucas
Jay Blanchard wrote: Good afternoon gurus and guru-ettes! I am searching for an algorithm that will take a list of monetary values and determine which of these values totals a value supplied to the widget. 1. I supply a value to the application and give a date range 2. The application will quer

RE: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Jay Blanchard
[snip] So imagine the value of all of your items is equal to it's size. Voila, same problem. [/snip] Got it. I was focused to much on the forest and not the trees. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Instruct ICC
> CC: php-general@lists.php.net > From: [EMAIL PROTECTED] > Date: Tue, 9 Oct 2007 15:58:22 -0400 > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Looking for help with a complex algorithm > > And that is when I realize how much more I still need to learn about > php... IMHO

RE: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Instruct ICC
I never heard of the knapsack problem before this post. But the w in the w*x terms appear to be 1, and he seems to want an exact value, not "less than or equal to". I think my brute force factorial technique is a solution, but dynamic programming may be more efficient? Not familiar with DP alth

RE: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Robert Cummings
On Tue, 2007-10-09 at 15:28 -0500, Jay Blanchard wrote: > [snip] > This *IS* the knapsack problem. Just because you specify date ranges to > get your values and the value isn't a knapsack doesn't change the fact > that it is the same problem :) I remember having fun with genetic > algorithms and th

Re: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Daniel Brown
On 10/9/07, Jay Blanchard <[EMAIL PROTECTED]> wrote: > [snip] > This *IS* the knapsack problem. Just because you specify date ranges to > get your values and the value isn't a knapsack doesn't change the fact > that it is the same problem :) I remember having fun with genetic > algorithms and the k

RE: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Jay Blanchard
[snip] This *IS* the knapsack problem. Just because you specify date ranges to get your values and the value isn't a knapsack doesn't change the fact that it is the same problem :) I remember having fun with genetic algorithms and the knapsack problem back in University. [/snip] You're right save

Re: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Robert Cummings
On Tue, 2007-10-09 at 14:01 -0500, Jay Blanchard wrote: > Good afternoon gurus and guru-ettes! > > I am searching for an algorithm that will take a list of monetary values > and determine which of these values totals a value supplied to the > widget. > > 1. I supply a value to the application and

Re: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Jason Pruim
And that is when I realize how much more I still need to learn about php... On Oct 9, 2007, at 3:01 PM, Jay Blanchard wrote: Good afternoon gurus and guru-ettes! I am searching for an algorithm that will take a list of monetary values and determine which of these values totals a value sup

RE: [PHP] Looking for help with a complex algorithm

2007-10-09 Thread Instruct ICC
> Date: Tue, 9 Oct 2007 14:01:30 -0500 > From: [EMAIL PROTECTED] > To: php-general@lists.php.net > Subject: [PHP] Looking for help with a complex algorithm > > Good afternoon gurus and guru-ettes! > > I am searching for an algorithm that will take a list of monetary values > and determine which o