If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#2
|
|||
|
|||
find sum in list of of numbers
You're right, Jim, the OP could reduce his solution space by
disregarding the numbers greater than his "target" number. In an accounting environment, however, debits and credits (positive as well as negative) may need to be considered- the negative numbers may react with the positive larger numbers to arrive at the correct solution. |
#3
|
|||
|
|||
find sum in list of of numbers
I do agree that Harlan's code looks good. I haven't tried to compile and run
it, but it looks like a good approach. Bill ------------------------------ Jim Thomlinson wrote: I am with you on the brute force requirement, but there are a couple of tricks to minimize the permiutations and combinations. By sorting the list of input values you can determine to stop testing certain combinations knowing that certain solutions can not be possible because they are going to be too large. That is where the code that I posted is very good. I had some other code that did almost exactly what you were suggesting but it was far slower. From what I have seen Harlan's code is hard to beat. That being said the list you are searching should be at most 25 or 30 entries. |
#4
|
|||
|
|||
find sum in list of of numbers
Use Google's group search: http://groups.google.com/advanced_group_search
, look in Groups *excel*, with all of the words Add up numbers, Author Harlan (yes, indeed, Harlan Grove) and you'll find a discussion and very advanced solutions about this subject -- Kind regards, Niek Otten "Dave O" wrote in message ups.com... You're right, Jim, the OP could reduce his solution space by disregarding the numbers greater than his "target" number. In an accounting environment, however, debits and credits (positive as well as negative) may need to be considered- the negative numbers may react with the positive larger numbers to arrive at the correct solution. |
#5
|
|||
|
|||
find sum in list of of numbers
Sorry, I missed that it had already been mentioned here
-- Kind regards, Niek Otten "Niek Otten" wrote in message ... Use Google's group search: http://groups.google.com/advanced_group_search , look in Groups *excel*, with all of the words Add up numbers, Author Harlan (yes, indeed, Harlan Grove) and you'll find a discussion and very advanced solutions about this subject -- Kind regards, Niek Otten "Dave O" wrote in message ups.com... You're right, Jim, the OP could reduce his solution space by disregarding the numbers greater than his "target" number. In an accounting environment, however, debits and credits (positive as well as negative) may need to be considered- the negative numbers may react with the positive larger numbers to arrive at the correct solution. |
#6
|
|||
|
|||
find sum in list of of numbers
That is not quite what the code does. What it does is it sorts the original
values lowest to highest. Negatives will obviously be the lowest values. When it is doing the combinations it moves in the direction of adding the next highest number. If the combination exceeds the target value then it abandons moving to the following next highest value because it obviously is not a possible solution. I am not sure that I explained that very well but sufice it to say that it works and it speeds up the execution by potentially a few orders of magnitude. -- HTH... Jim Thomlinson "Dave O" wrote: You're right, Jim, the OP could reduce his solution space by disregarding the numbers greater than his "target" number. In an accounting environment, however, debits and credits (positive as well as negative) may need to be considered- the negative numbers may react with the positive larger numbers to arrive at the correct solution. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
find sum in list of of numbers | Ron Coderre | New Users | 10 | January 5th, 2006 08:26 AM |
find sum in list of of numbers | Jim Thomlinson | New Users | 3 | January 4th, 2006 09:58 PM |
Query to find missing numbers | Randy | Running & Setting Up Queries | 3 | December 7th, 2004 10:51 PM |
synchronizing form and list box | Deb Smith | Using Forms | 8 | June 21st, 2004 08:15 PM |
Create a randomly sorted list from selected numbers | Twofingers | Worksheet Functions | 6 | December 31st, 2003 11:49 PM |