서로 다른 n개에서 중복이 가능하게 r개를 뽑아서 정렬하는 경우의 수
서로 다른 n개의 원소를 가지고 중복을 허용하여 r개의 원소를 선택하는 것
from itertools import product
for i in product([1,2,3], repeat=2):
print(i, end=" ")
서로 다른 n개에서 순서 없이, 중복이 가능하게 r개를 뽑는 경우의 수
서로 다른 n개의 원소를 가지고 순서 없이, 중복을 허용하여 r개의 원소를 선택하는 것
Input: [1, 2, 3]
Output: [ [1, 1], [1, 2], [1, 3], [2, 2], [2, 3], [3, 3] ]
from itertools import combinations_with_replacement
for cwr in combinations_with_replacement([1,2,3], 2):
print(cwr, end=" ")