Programming Language/Python
Python itertools를 이용한 순열과 조합 (combinations, permutations)
hackyu
2019. 10. 9. 07:05
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
import itertools
abc = [1,2,3,4]
#abc = ['a','b','c','d']
b = itertools.permutations(abc, 3) #target, length(Non-Essential)
for i in b:
#i = list(i)
print(list(i))
b = itertools.combinations(abc, 2) #target, length(Essential)
for i in b:
#i = list(i)
print(list(i))
|
|