import sys
input=sys.stdin.readline
res=[]
from itertools import combinations
while True:
arr=list(map(int, input().split()))
if len(arr)==1 and arr[0]==0:
break
for i in list(combinations(arr[1::], 6)):
for j in i:
print(j, end=" ")
print()
print()
import itertools
import sys
while True:
numbers=list(map(int,sys.stdin.readline().split()))
k=numbers[0]
if k==0:
break
s=numbers[1:]
combi=itertools.combinations(s,6)
for i in combi:
print(*i)
print()
from itertools import combinations
import sys
input = sys.stdin.readline
while True:
n_list = list(map(int, input().split()))
if n_list[0] == 0:
break
for c in combinations(n_list[1:], n_list[0]):
for a in combinations(c, 6):
print(' '.join(map(str, a)))
print()
from itertools import combinations
while True:
li = []
num = list(map(int, input().split()))[1:]
if not num:
break
for i in combinations(num, 6):
li.append(i)
li.sort()
for i in li:
print(*i)
print()
순열 (permutations): 서로 다른 n개에서 r개를 뽑아서 정렬하는 경우의 수
- (1, 2) (1, 3) (1, 4) (2, 1) (2, 3) (2, 4) (3, 1) (3, 2) (3, 4) (4, 1) (4, 2) (4, 3)
조합 (combinations) : 서로 다른 n개에서 순서 없이 r개를 뽑는 경우의 수
- (1, 2) (1, 3) (1, 4) (2, 3) (2, 4) (3, 4)
중복 순열 (product) : 서로 다른 n개에서 중복이 가능하게 r개를 뽑아서 정렬하는 경우의 수
- (1, 1) (1, 2) (1, 3) (2, 1) (2, 2) (2, 3) (3, 1) (3, 2) (3, 3)
중복 조합 (combinations_with_replacement) : 서로 다른 n개에서 순서 없이, 중복이 가능하게 r개를 뽑는 경우의 수
- (1, 1) (1, 2) (1, 3) (1, 4) (2, 2) (2, 3) (2, 4) (3, 3) (3, 4) (4, 4)
- 순열과 조합의 차이
- 순열은 : [2,1] 과 [1,2]를 다른 것으로 봄
- nPr = n! // (n-r)!- 조합은 : [2,1] 과 [1,2]를 같은 것으로 봄
- nCr = n! // ((n-r)!*r!)