250x250
반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- flask
- session 유지
- Airflow
- API Gateway
- chatGPT
- correlation
- BigQuery
- subdag
- 상관관계
- API
- TensorFlow
- top_k
- login crawling
- gather_nd
- GenericGBQException
- spark udf
- airflow subdag
- tensorflow text
- Counterfactual Explanations
- GCP
- UDF
- Retry
- requests
- hadoop
- 유튜브 API
- integrated gradient
- 공분산
- XAI
- grad-cam
- youtube data
Archives
- Today
- Total
데이터과학 삼학년
순열과 조합 구하기 (Permutation & Combination) 본문
반응형
파이썬에서 순열과 조합의 경우를 구하는 방법
itertools를 이용하자!
Permutation (순열)
import itertools
for perm in itertools.permutations(['a','b','c']):
print(perm)
# ===
('a', 'b', 'c')
('a', 'c', 'b')
('b', 'a', 'c')
('b', 'c', 'a')
('c', 'a', 'b')
('c', 'b', 'a')
Combination (조합) -3C2
[1,2,3] 에서 2개를 가지고 조합을 만들때, itertools.combinations(list, <만들 조합원소수>)
import itertools
for comb in itertools.combinations(['a','b','c'],2):
print(comb)
# ===
('a', 'b')
('a', 'c')
('b', 'c')
728x90
반응형
LIST
'Python' 카테고리의 다른 글
| 정규 표현식 기초 (퍼옴) (0) | 2021.03.23 |
|---|---|
| 코루틴 (coroutine) 정리 (1) | 2021.01.01 |
| python custom import path 지정 (0) | 2020.07.15 |
| argparse 리스트(list), boolean(True or False) 를 파라미터로 받는 방법 (1) | 2020.07.09 |
| First Class Function (일급 함수) (0) | 2020.04.13 |
Comments