Use the position of
1 in bites to calculate all the possibilities of combinations in a list.
0 0 0 0 0to indicate all the items’ positions, and
1can be every position in the bits. All the combinations should be the Powerset we want to, then use
>>to check every combination’s position whether it is 1 or not.
itertools.combinations to calculate r length subsequences of elements, then iterate with different length.
combinationsis a little complicated, added some notations to help me to understand.
from itertools import chain