Thief of Wealth
Published 2019. 3. 24. 17:25
python 조합 개발/Python

조합은 순열이긴한데 그 순열들의 요소의 순서가 달라도 같은 요소들만 있다면 중복으로 보는 특성을 가진다.


a,b나 b,a나 똑같은 것으로 보는 것이다.


이것도 간단하게 python의 itertools로 해결할 수 있다.


사용법은 permutation과 같다.



import itertools


a = [1,2,3,4]


a_permutaion = list(itertools.combinations(a,2)) # a의 원소로 2개의 원소를가진 조합생성


print(a_permutaion)


'개발 > Python' 카테고리의 다른 글

Ubuntu python pip 설치하기  (0) 2019.03.28
python itertools product  (0) 2019.03.24
python 순열  (0) 2019.03.24
python 유효범위  (0) 2019.03.24
python join함수  (0) 2019.03.24
profile on loading

Loading...