toutes les permutations python
import itertools
print(list(itertools.permutations([1,2,3])))
Smiling Sable
import itertools
print(list(itertools.permutations([1,2,3])))
import itertools
a = [1, 2, 3]
n = 3
perm_iterator = itertools.permutations(a, n)
for item in perm_iterator:
print(item)
import itertools
list(itertools.permutations([1, 2, 3]))
def permute(LIST):
length=len(LIST)
if length <= 1:
yield LIST
else:
for n in range(0,length):
for end in permute( LIST[:n] + LIST[n+1:] ):
yield [ LIST[n] ] + end
for x in permute(["3","3","4"]):
print x
>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms