Say, I have a set of numbers that always has an even count. i.e. num=[2,4,6,10,8,7,4,5], 8 numbers.
I want to find all possible combinations of two subset of these numbers (using each of them) that have equal count (4 each), and have the closest possible sum - equal sum if achievable .
For example:
a1 = 10 + 2 + 6 + 4 = 22
b1 = 8 + 7 + 4 + 5 = 24,
a2 = 10 + 6 + 5 + 2 = 23
b2 = 7 + 4 + 8 + 4 = 23,
. . .
I looked up some other questions that were asked, but they did not have these constraints in them. In Excel, I am using ''solver'' to solve this and I m wondering if it could be solved in python.