6
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
import math
import itertools
n = 3
print(math.factorial(n))
perm = itertools.permutations(list(range(1, n + 1)))
for i, j in enumerate(list(perm)):
permutation = ''
for item in j:
permutation += str(item) + ' '
print(permutation)
No comments:
Post a Comment