。。
With given l = [1,0]
and n = 2
I should get k = 5
elements and the result should look like this:
results = [11111,11110,11101,11100,11001,11011,11010,...00000]
最佳答案
>>> import itertools
>>> ["".join(item) for item in itertools.product("10", repeat=5)]
['11111', '11110', '11101', '11100', '11011', '11010', '11001', '11000', '10111',
'10110', '10101', '10100', '10011', '10010', '10001', '10000', '01111', '01110',
'01101', '01100', '01011', '01010', '01001', '01000', '00111', '00110', '00101',
'00100', '00011', '00010', '00001', '00000']