목록itertools (1)
minimimi
[Python] 순열, 조합, 중복순열, 중복조합
1. 순열 permutations(Iterable, r) # 순열 from itertools import permutations for i in permutations([1,2,3,4], 2): print(i, end=" ") # (1, 2) (1, 3) (1, 4) (2, 1) (2, 3) (2, 4) (3, 1) (3, 2) (3, 4) (4, 1) (4, 2) (4, 3) 2. 조합 combinations(Iterable, r) # 조합 from itertools import combinations for i in combinations([1,2,3,4], 2): print(i, end=" ") # (1, 2) (1, 3) (1, 4) (2, 3) (2, 4) (3, 4) 3. 중복순열 produc..
프로그래밍 공부/Python
2021. 9. 30. 18:00