백준 Algorithm

[백준 6603 로또 문제] PYTHON

harry595 2021. 8. 10. 21:45

15649 문제와 동일하다. 기본적으로 BackTracking 문제이지만

itertools의 combinations를 사용하면 간단히 풀 수 있다.

 

from itertools import combinations

while True:
    A = list(map(int, input().split()))[1:]
    if not A:
        break
    permute = combinations(A, 6)
    for perm in list(permute):
        for per in perm:
            print(per, end=' ')
        print()
    print()