I have a list of 11 numbers, and I want to test the product of all combinations against some rule (2^11 possibilities).
I came across this SO question, but it seems to return a list of all combinations, which I think would take up to much memory.
My C++ thinking would be to go through each binary number 0x001
to 0x7FF
and multiply each number where its corresponding bit is 1.
Example with 4 numbers: My list is [2, 3, 5, 7]
The first binary number would be 0001
giving - 2 = 2
Later we would get to 1110
and the product would be 3 * 5 * 7 = 105
Is there a better way of doing this in python
? A bit manipulation doesn't seem like the right way to go.