Все перестановки 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
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]))
>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms
T=[i for i in range(8)]
for i in range(8):
print("T[",i,"]= ",end="")
T[i]=int(input())
print("Tableau avant permutation")
print(T)
k=7
for i in range(4):
X=T[i]
T[i]=T[k]
T[k]=X
k=k-1
print("Tableau après permutation")
print(T)