RE: [PHP] Number Comparisons
| From: | Maxim Maletsky | Date: | Mon, 02 Oct 2000 11:37:43 +0000 |
| Subject: | RE: [PHP] Number Comparisons | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18268@lists.php.net to get a copy of this message | ||
Nice Question, Man....
I've been looking for something similar once and then just gave up replacing
it with some different, less accurate solution, even if in mathematics I am
OK..
Good Luck, man, sorry cannot help you on this, hope you will find here an
answer.
-----Original Message-----
From: Real GM Webmaster [mailto:db7@realgm.com]
Sent: Monday, October 02, 2000 9:28 PM
To: php-general@lists.php.net
Subject: [PHP] Number Comparisons
Hi,
I have a problem that has had be scratching my head for the last three
weeks.
What I need to do is take a number, say 40, and then have a varying number
of other integers that I need to find the best fit into the original number.
There could be four, give, or 25 numbers that could fit.
For example, using 40 as the basis.
Just say on the flip side I have 20, 9, 7, 5, and 2.
I need to find the sum of these numbers that will end up closest to 40. In
this case the numbers that would be returned would be 20, 9, 7 and 2, which
equals 38.. 5 would be left over. Any other sum would either push me over
the 40 mark or would fall short of the 38.
Any idea on how to do this. Remember, that the number of numbers that will
be compared is not static.
Please help me, because I am completely stuck and this is vital to the
accuracy of our site.
Thank you in advance,
Michael.