Have a good day. I have tried to find a real solution for the sum of all possible combinations of an array but have not found any so far using python.
Commonly people ask about the following combinatorics:
Given: a, b, c, d and e as records:
a+b
a+c
a+d
a+e
b+c
b+d
b+e
c+d
c+e
d+e
The real combination would be:
a+b
a+c
a+d
a+e
a+b+c
a+b+d
a+b+e
a+c+d
a+c+e
a+d+e
a+b+c+d
a+b+c+e
a+c+d+e
a+b+c+d+e
b+c
b+d
b+e
b+c+d
b+c+e
b+d+e
c+d
c+e
c+d+e
d+e
So, the result I need to obtain is the following, but so far I have not found how to iterate it to cover any size of the array:
| COMBINATION | SUM |
|-------------|--------------|
|a+b | XXX|
|a+c | XXX|
|a+d | XXX|
|a+e | XXX|
|a+b+c | XXX|
|a+b+d | XXX|
|a+b+e | XXX|
|a+c+d | XXX|
|a+c+e | XXX|
|a+d+e | XXX|
|a+b+c+d | XXX|
|a+b+c+e | XXX|
|a+c+d+e | XXX|
|a+b+c+d+e | XXX|
|b+c | XXX|
|b+d | XXX|
|b+e | XXX|
|b+c+d | XXX|
|b+c+e | XXX|
|b+d+e | XXX|
|c+d | XXX|
|c+e | XXX|
|c+d+e | XXX|
|d+e | XXX|
Note that the combination size is variable and must cover the total number of records in the array. Anyone have any ideas, possibly with the mathematical algorithm that is actually being applied here?