So I have a dilemma. I have to figure out which 4 numbers of these add up to 271.12? I have no idea if it is possible, I'm 90% sure. Is there a website or a formula to use to figure this out?
------
62.15
191.62
158.78
150.75
116.05
96.02
52.53
51.43
40.23
39.00
25.00
21.87
20.53
20.00
19.64
15.78
9.83
9.69
6.02
4.96
4.93
------
62.15
191.62
158.78
150.75
116.05
96.02
52.53
51.43
40.23
39.00
25.00
21.87
20.53
20.00
19.64
15.78
9.83
9.69
6.02
4.96
4.93
-
It's not possible. This type of problem (generalized a bit) is called the subset sum problem, and is known to be quite difficult in general. For relatively small list sizes like yours, it can be brute-forced. I wrote an ugly Python script to handle your particular problem. It tried all possibilities, and the closest it found was
191.62, 39.00, 20.53, 20.00
Some question I answered a while back asked essentially this question in the context of Excel. They found an Excel file to solve their problem via brute force.
191.62, 39.00, 20.53, 20.00
Some question I answered a while back asked essentially this question in the context of Excel. They found an Excel file to solve their problem via brute force.
-
This is very frustrating. I have tried this for a while now. At first I was looking for a systematic way to find the answer using the fact 272.12 = 6803 / 25, however that led me no where and then after several minutes of a brute force attack - I find myself exceeding the value by .12 many times. I am pretty sure there are programs out there that can find that in array of numbers if two of the numbers can add up to a particular value, as far as four goes, I am not sure.
This is a very interesting dilemma. Brute force attack won't work, my only helpful suggestion is trying to add two values by brute force then doing 272.12 - (Their Sum), and then using a program to find if the other values in the array can add up to the difference.
http://www.kirupa.com/forum/showthread.p…
However, it will not work, if the value of x is 2 times the value of any number in the array, which makes it difficult to use in your case seeing as you have very high and low numbers. If you have some knowledge in programming then you may be able to alter the code to fit your needs. I personally do not have any programming knowledge as of yet.
Probability speaking the chance of a brute force attacking being successful with this amount of numbers (assuming that it is in fact possible to get 272.12) is extremely low.
---------------
Sorry I could not be much help, but just wanted to reply seeing as no one else had an answer.
-----------------
I just realized all this time I was looking for 272.12 instead of 271.12, wow I might have even come up with the solution without realizing it. I am working on it again and if I figure out an answer I will edit it in.
----------------
Looks like programming is the way to go with this problem. Josh certainly saved me a great deal of time and frustration. Definitely give him BA.
This is a very interesting dilemma. Brute force attack won't work, my only helpful suggestion is trying to add two values by brute force then doing 272.12 - (Their Sum), and then using a program to find if the other values in the array can add up to the difference.
http://www.kirupa.com/forum/showthread.p…
However, it will not work, if the value of x is 2 times the value of any number in the array, which makes it difficult to use in your case seeing as you have very high and low numbers. If you have some knowledge in programming then you may be able to alter the code to fit your needs. I personally do not have any programming knowledge as of yet.
Probability speaking the chance of a brute force attacking being successful with this amount of numbers (assuming that it is in fact possible to get 272.12) is extremely low.
---------------
Sorry I could not be much help, but just wanted to reply seeing as no one else had an answer.
-----------------
I just realized all this time I was looking for 272.12 instead of 271.12, wow I might have even come up with the solution without realizing it. I am working on it again and if I figure out an answer I will edit it in.
----------------
Looks like programming is the way to go with this problem. Josh certainly saved me a great deal of time and frustration. Definitely give him BA.