Koala - 7기/코딩테스트 준비 스터디

[BOJ / Python] 6603 - 로또

재우신 2022. 7. 8. 15:56

백준 6603번 로또

Intro

Solution

nC6 조합을 구하여 모두 출력하는 문제. 파이썬 내장 itertools 라이브러리의 combinations 메소드를 사용하여 조합을 만들고 모두 출력하여 간단하게 풀이할 수 있다.

Code

from itertools import combinations as cb
def solve():
    while True:
        k, *S = input().split()
        if k == '0': break
        [print(" ".join(s)) for s in cb(S, 6)]
        print()

solve()