728x90
-
- itertools: 경우의 수를 찾을 때 사용되는 라이브러리 (import itertools)
- itertools.permutations: 순서는 중요하고 중복은 허용되지 않음.
ex) itertools.permutations([1, 2, 3], 2) => [(1,2), (1,3), (2,1), (2,3), (3,1), (3,2)] - itertools.product: 순서는 중요하고 중복은 허용됨.
ex) itertools.product([1, 2, 3], 2) => [(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3)] - itertools.combinations: 순서는 중요하지 않고 중복은 허용되지 않음.
ex) itertools.combinations([1, 2, 3], 2) => [(1,2), (1,3), (2,3)] - itertools.combinations_with_replacement: 순서는 중요하지 않고 중복은 허용됨.
ex) itertools.combinations_with_replacement([1, 2, 3], 2) => [(1,1), (1,2), (1,3), (2,2), (2,3), (3,3)]
- itertools.permutations: 순서는 중요하고 중복은 허용되지 않음.
- itertools: 경우의 수를 찾을 때 사용되는 라이브러리 (import itertools)
728x90
'Programming > Python' 카테고리의 다른 글
[Python] 코딩테스트에서 자주 사용되는 주요 라이브러리 (0) | 2021.08.12 |
---|---|
[Python] 2차원 리스트 초기화하기 (1) | 2021.08.11 |
[Python] map(): 리스트의 형식 변환(문자열->숫자 or 숫자->문자열) (0) | 2021.08.03 |
[Python] Counter: list 요소 개수 세어서 dictionary로 출력 (0) | 2021.07.11 |
[Python] 딕셔너리 dictionary (0) | 2021.07.11 |