목록모듈 (1)
눈송이의 개발생활
[Python]itertools - permutations, combinations (순열과 조합)
자주 쓰이는 순열, 중복순열, 조합, 중복조합 구현하기 itertools 공식문서에 따르면 itertools는 효율적인 루핑을 위한 iterator를 만드는 함수라고 한다 해당 모듈에는 다양한 함수들이 있다 그 중 자주 나오는 순열 조합 함수들에 대해 정리해 볼 것이다 📌 permutations from itertools import permutations arr = [1, 2, 3, 4] print(permutations(arr, 2)) print(list(permutations(arr, 2))) # # [(1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)] permutations(li..