In the manual: http://docs.python.org/2.7/library/itertools.html#itertools.permutations
Elements are considered unique, based on their position, and not on their value. Therefore, if the input elements are unique, there will be no duplicate values in each permutation.
This means that it itertools.permutations('000')
will happily give you 3! = 6, where everything is '000'
.
: http://ideone.com/gzqolT
, . itertools.combinations(S,r)
S
r
. S = range(7)
r = 3
.
:
list('{0:07b}'.format(sum(subset))
for subset in itertools.combinations((2**s for s in range(7)), 3))
:
(2**s for s in range(7))
2 2 ^ 6.itertools.combinations(…, 3)
3 2.sum(subset)
, . [1,2,4]
= 7.'{0:07b}'.format(…)
int , 7.