python/모듈
[Python] 순열과 조합
wjwkddyd221001
2023. 2. 8. 22:53
순열
- nPr : 서로 다른 n개에서 p개를 골라 순서를 정해 나열하는 경우의 수
from itertools import permutations
# n은 서로 다른 n개를 담고 있는 list
nPr = permutations(n, r)
조합
- nCr : 서로 다른 n개에서 p개를 골라 순서를 고려하지 않고 나열하는 경우의 수
from itertools import combinations
nCr = combinations(n, r)