def fc(n):
'''find full combinations for 1-n,
using bitmap method. '''
comb = []
for i in range(2**n-1, 0, -1):
b = str(bin(i))[2:].zfill(n)
out = [range(1, n+1)[int(k)] for k, j in enumerate(b) if j == '1']
comb.append(out)
return comb
网友评论