permutations(반복 가능한 객체, n) // n=몇개를 뽑을 것인지
from itertools import permutations
print(list(permutations([1,2,3,4], 2)))
print(list(permutations([1,2,3,1], 2)))
# result1
# [(1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)]
# result2
# [(1, 2), (1, 3), (1, 1), (2, 1), (2, 3), (2, 1), (3, 1), (3, 2), (3, 1), (1, 1), (1, 2), (1, 3)]
product(반복 가능한 객체, repeat=num)
from itertools import product
print(list(product([1,2,3,4], repeat=2)))
print(list(product([1,2,3,1], repeat=2)))
# result1
# [(1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4)]
# result2
# [(1, 1), (1, 2), (1, 3), (1, 1), (2, 1), (2, 2), (2, 3), (2, 1), (3, 1), (3, 2), (3, 3), (3, 1), (1, 1), (1, 2), (1, 3), (1, 1)]
combinations(반복 가능한 객체, n) // n=몇개를 뽑을 것인지
from itertools import combinations
print(list(combinations([1,2,3,4], 2)))
print(list(combinations([1,2,3,1], 2)))
# result1
# [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
# result2
# [(1, 2), (1, 3), (1, 1), (2, 3), (2, 1), (3, 1)]
combinations_with_replacement(반복 가능한 객체, n) // n=몇개를 뽑을 것인지
from itertools import combinations_with_replacement
print(list(combinations_with_replacement([1,2,3,4], 2)))
print(list(combinations_with_replacement([1,2,3,1], 2)))
# result1
# [(1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4)]
# result2
# [(1, 1), (1, 2), (1, 3), (1, 1), (2, 1), (2, 2), (2, 3), (2, 1), (3, 1), (3, 2), (3, 3), (3, 1), (1, 1), (1, 2), (1, 3), (1, 1)]