티스토리 뷰

python lecture/basic

[edu] 순열, 조합

burningrizen 2018. 11. 13. 14:09

[순열]



중복 없음


import itertools

nums_a = [1, 2, 3]
permu_a = itertools.permutations(nums_a, 2)



중복


import itertools

nums_a = [1, 2, 3]
permu = itertools.product(nums_a, repeat=2)



[조합]



중복 없음


import itertools

nums_a = [1, 2, 3]
permu = itertools.combinations(nums_a, repeat=2)


중복


import itertools

nums_a = [1, 2, 3]
permu = itertools.combinations_with_replacement(nums_a, repeat=2)




댓글