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 | 29 | 30 |
Tags
- pulloff
- model-free control
- loss functions
- objective functions for machine learning
- straightup
- freebooze
- thresholding
- MRI
- Knowledge Distillation
- Policy Gradient
- remove outliers
- 자료구조
- normalization
- Inorder Traversal
- REINFORCE
- 3d medical image
- domain adaptation
- fastapi
- checkitout
- rest-api
- clip intensity values
- non parametic softmax
- sidleup
- noise contrast estimation
- sample rows
- resample
- scowl
- Excel
- shadowing
- Actor-Critic
Archives
- Today
- Total
Let's Run Jinyeah
[Python] list 원소의 모든 조합 구하기 본문
1. 하나의 리스트에서 모든 조합 구하기 - itertools의 permutations 또는 combinations이용
from itertools import permutations
letters = ['a', 'b', 'c']
result = list(permutations(items, 2))
result = list(map(''.join, result))
# ['ab', 'ac', 'ba', 'bc', 'ca', 'cb']
from itertools import combinations
letters = ['a', 'b', 'c']
result = list(permutations(items, 2))
result = list(map(''.join, result))
# ['ab', 'ac', 'bc']
2. 두개 이상의 리스트에서 모든 조합 구하기 - itertools의 product 이용
from itertools import product
letters = [['a','b','c'], ['d','e','f']]
result = list(product(*letter_list))
result = list(map(''.join, result))
# ["ad","ae","af","bd","be","bf","cd","ce","cf"]
'Programming > Algorithm' 카테고리의 다른 글
| Outer product, Inner product (0) | 2022.10.06 |
|---|---|
| [Python] Data Structure - Tree (0) | 2021.10.19 |
| [Python] 이진탐색 (0) | 2021.10.19 |
| [Python] 정렬 - 선택, 삽입, 퀵 (0) | 2021.10.14 |
| [Python] 기본 탐색 - 완전탐색, DFS/BFS (0) | 2021.10.14 |
Comments