모든 경우의 수를 순서대로 살펴볼 때 사용한다.
Python
from intertools import permutations
v = [1, 2, 3, 4]
for i in permutation(v, 4): # 인자가 2개 들어감. 리스트, 몇 개를 할지 숫자
print(i)
↓ 출력 값
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
....
4 3 1 2
4 3 2 1
파이썬에서 사용할 수 있는 모듈
from itertools import combinations
v = [1, 2, 3, 4]
for i in combinations(v, 2):
print(i)
↓ 출력값
1 2
1 3
1 4
2 3
2 4
3 4