CS/Python
[Python] itertools 라이브러리
from itertools import * 1. 순열 ▪ permutations 구성 요소가 같더라도 순서가 다르면 나열 중복이 없는 모든 경우의 수 나열 from itertools import permutations data = [ 1, 2, 3 ] list(permutations(data, 2) [(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)] list(permutations(data, 2) [(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)] 2. 중복 순열 순열에서 같은 요소를 상관없이 중복 포함하여 모두 나열 from itertools import * data = [ 1, 2, 3 ] list..
2023. 7. 1.