|
||
|
|
|||||||
| Welcome to the Exploding Garrmondo Weiner Interactive Swiss Army Penis. |
|
GFF is a community of gaming and music enthusiasts. We have a team of dedicated moderators, constant member-organized activities, and plenty of custom features, including our unique journal system. If this is your first visit, be sure to check out the FAQ or our GFWiki. You will have to register before you can post. Membership is completely free (and gets rid of the pesky advertisement unit underneath this message).
|
![]() |
|
|
Thread Tools |
The size of the limit variable would have a dependence on the size of the set, but its a statistical dependence on the variance in the set coupled with the number of solutions you want to retain, not just the total numbers (at least for reasonably small groups).
However, there's really no point if you just want the closest combo, as you can brute force a converging limit by taking the difference on each try, storing it as a min difference, and then discarding anything that doesn't meet that min. No guesswork on what to throw away, and it converges quite fast. Jam it back in, in the dark. |
If you want a long list of potential matches, then the limit depends on: the length of the list, the variance of the list, and how many matches you want. More than that, I can't say, as its complex.
If you want one match, then just do a brute force. if( tolerance > LastTotal1Diff ){ tolerance = LastTotal1Diff; } which will end up with the closest match for your first sum if you assign Total1Diff to LastTotal1Diff at the end of each successful loop. You could also do minima of the total difference for both sets if they weren't going to add up to such a close set of numbers. You can also solve this in Excel using packrat's general strategy, if you don't like coding. X columns for the bit mask, X columns for your numbers, summary columns that give the totals, columns for the differences, and a column for the difference total. In a simple form with three numbers. Code:
Target 1 Target 2 100000 20000 Bit 1 Bit 2 Bit 3 30405 2103 128923 Sum 1 Sum 2 Diff 1 Diff 2 Diff Total 0 0 0 0 0 0 0 161431 100000 141431 241431 0 0 1 0 0 128923 128923 32508 28923 12508 41431 0 1 0 0 2103 0 2103 159328 97897 139328 237225 0 1 1 0 2103 128923 131026 30405 31026 10405 41431 1 0 0 30405 0 0 30405 131026 69595 111026 180621 1 0 1 30405 0 128923 159328 2103 59328 17897 77225 1 1 0 30405 2103 0 32508 128923 67492 108923 176415 1 1 1 30405 2103 128923 161431 0 61431 20000 81431 There's nowhere I can't reach. |