Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- KLUE
- AI Math
- Ai
- AI 경진대회
- Data Viz
- ODQA
- seaborn
- matplotlib
- mrc
- 현대자동차
- Attention
- word2vec
- RNN
- nlp
- 딥러닝
- pyTorch
- Transformer
- 데이터 시각화
- 2023 현대차·기아 CTO AI 경진대회
- Bart
- N2N
- N21
- passage retrieval
- 기아
- Bert
- Self-attention
- Optimization
- 데이터 구축
- dataset
- GPT
Archives
- Today
- Total
쉬엄쉬엄블로그
Python permutations 본문
728x90
순열을 구할 수 있는 함수 permutations
from itertools import permutations
a = [1, 2, 3]
permutations(a, 2)
=> a 리스트의 원소들 중 2개를 추출하여 만들 수 있는 모든 순서쌍을 객체로 반환
list(permutations(a, 2))
=> [(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)]
참고
조합을 구할 수 있는 함수 combinations
list(combinations(a, 2))
=> [(1, 2), (1, 3), (2, 3)]
- 순열은 순서를 고려함
- 조합은 순서를 고려하지 않음
'코딩' 카테고리의 다른 글
Python set (0) | 2022.04.14 |
---|---|
Python collections (0) | 2022.04.14 |
Python PriorityQueue (0) | 2022.04.09 |
Python any(), all() (0) | 2022.04.02 |
Python deque (0) | 2022.03.29 |
Comments