The easiest hard problem (partition)
Posted: Mon May 16, 2016 3:58 pm
You can read about it in the Scientific American, it´s by Brian Hayes.
If we have a big number of numbers how to divide them so that the two groups are equal ?
It seems that the algorithm for this has not been found yet.
My suggestion:
Make a sum of all numbers, divide in half.
If the number is straight then good, if not then it´s not too bad.
Let´s call this number the aim number.
Then add the first two numbers and try to find if any of the remaining numbers fills the gap between this preliminary sum and the aim number.
If not, add one more and see again.
It´s not perfect yet, but what do you think ?
It´s better than the greedy algorithm, isn´t it ?
5, 24, 598, 6, 29, 30
Sum: 692
half: 346
5 + 24 = 26
gap between 26 and 346 = 320
but 598 is sticking out as too big
An extra algorithm should find out that there is no solution because one number is bigger than the half of all of them.
If we have a big number of numbers how to divide them so that the two groups are equal ?
It seems that the algorithm for this has not been found yet.
My suggestion:
Make a sum of all numbers, divide in half.
If the number is straight then good, if not then it´s not too bad.
Let´s call this number the aim number.
Then add the first two numbers and try to find if any of the remaining numbers fills the gap between this preliminary sum and the aim number.
If not, add one more and see again.
It´s not perfect yet, but what do you think ?
It´s better than the greedy algorithm, isn´t it ?
5, 24, 598, 6, 29, 30
Sum: 692
half: 346
5 + 24 = 26
gap between 26 and 346 = 320
but 598 is sticking out as too big
An extra algorithm should find out that there is no solution because one number is bigger than the half of all of them.