|
||
|
|
|||||||
| 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 |
I don't know about in excel, but I figure something like this would be very feasible in C.
A solution that I came up with was to place all your numbers into a matrix, and have another matrix of the same length defined by a 25-bit binary(0000000000000000000000001), starting with one. You multiply the sample set with your binary matrix and then sum the values in the result. Then compare the result with one of your two target values (i.e. 94,204,280). Next would be to establish a tolerance value to eliminate blatantly wrong solutions (say 500 or so). If your first result is within 500 of your target value, then have your program complement your binary matrix, multiply with the sample set matrix, and compare the sum of the resultant matrix with your second target (70,043,499). If it too is within 500, just have it display the binary value as well as each of the differences. The program will then increment the number defining the binary matrix (0000000000000000000000010) and start all over again, printing out all combinations that are within 500 of your targets. Afterward, you can scan through all of your results and select the solutions that have the smallest difference values and figure out the correct combination from the associated binary matrix. If you find you have way too many solutions popping up then you can just reduce your tolerance and run the program again. Sadly, this whole cycle will have to run about 33 million times, but I'm sure that and the associated programming are faster than checking all solutions through trial and error. This is similar to the method Secret Squirrel suggests, except without the genetic algorithm crap. You can be your own optimizing function. I'm sure there are many ways to streamline this process but I'll freely admit that I'm a godawful programmer. Additional Spam: Okay, so I ended up doing this in Matlab in a little under an hour. Your ideal solution is probably the following: 1. 508791 3. 60642 4. 1268384 5. 1831963 8. 1079081 10. 2755461 15. 6730411 17. 9865374 20. 22983457 24. 812882 25. 22147053 The above list summed = 70043499 (exactly as desired) and 2. 110776 6. 5141077 7. 2200967 9. 590535 11. 176599 12. 16323547 13. 1739899 14. 452583 16. 5657172 18. 561737 19. 36144212 21. 6164492 22. 8489925 23. 10450763 the above list summed = 94204284 (off by 4) In case you are curious, here is the program that I used to get the solution: Spoiler:
Jam it back in, in the dark. |
The script I posted is a brute force method which basically just avoids the comparative step Araes mentioned.
And yes, in my case, the limit variable is determined by the number of elements in your array. (you had 25, so 2^25 - 1 = 33554431) Here are a few modifications to the script I posted that will make it easier to scale to different data sets: Spoiler:
As stated earlier, this is a brute-force method that computes through every possible combination and then displays only those within a given tolerance value. Final discretion is left to the operator. When I ran this program, it was probably only 1/4 of the way through when it output a combination that gave differences of 0 and 4. I just stopped it there and recorded the combination, since I doubt you could get much better than that. I figure this script could actually be ported to C/C++, but I'm not the person to do that. There's nowhere I can't reach. |