[Python] combinations
조합(Combination)에 대해 간략하게 알아보도록 하겠습니다. 조합은 서로 다른 n개의 물건들 중 r개를 뽑아 순서가 없이 나열한 것이며 기호로 nCr와 같이 나타내고 중복은 불가능합니다. nCr의 팩토리얼을 이용한 계산 nPr/r! 즉 n!/(n-r)!/r!입니다.3개의 물건 중에 2개를 뽑은 경우의 수는 3입니다.nCr = 3!/(3-2)!/2! 즉 3 x 2 x 1 / (1) / 2 x 1로 6 / 2 = 3* 0! 은 1입니다. 1. 아래 코드 블록 itertools 라이브러리를 사용하여 작성한 코드입니다.from itertools import combinationstest_list = ['A', 'B', 'C']result = list(combinations(test_list, 2))pr..
Python
2022. 12. 28. 17:26
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- combinations
- Method
- index
- Lambda
- Lower
- function
- Built-in Functions
- isdigit
- for
- If
- Upper
- permutations
- zip
- operators
- counter
- Python
- isalpha
- find
- bool
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함