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)
from itertools import permutations
a=permutations([1,2,3,4],2)
for i in a:
print(i)
from itertools import permutations
string="SOFT"
a=permutations(string)
for i in list(a):
# join all the letters of the list to make a string
print("".join(i))
import itertools
list(itertools.permutations([1, 2, 3]))
def permutations(s):
if len(s) <= 1:
yield s
else:
for i in range(len(s)):
for p in permutations(s[:i] + s[i+1:]):
yield s[i] + p
input = 'ABCD'
for permutation in enumerate(permutations(input)):
print repr(permutation[1]),
print