*문제 출처는 백준에 있습니다.
문제 제목: 로또 / 6603번 (실버 2단계)
문제 사이트: https://www.acmicpc.net/problem/6603
문제 설명

나의 풀이
def dfs(lotto, start, current):
if len(current) == 6:
print(' '.join(current))
return
for i in range(start, len(lotto)):
current.append(lotto[i])
dfs(lotto, i + 1, current)
current.pop()
def main():
while True:
lotto = list(map(str, input().split()))
if lotto[0] == '0':
break
dfs(lotto, 1, [])
print()
if __name__=='__main__':
main()

※ 알아야 할 것
백트래킹을 이용하여 모든 경우의 수를 볼 수 있습니다!
'Coding Test > 백준-Python' 카테고리의 다른 글
| 백준 / 돌 게임 / 9655번 / Python (0) | 2025.05.14 |
|---|---|
| 백준 / RGB거리 2 / 17404번 / Python (0) | 2025.05.13 |
| 백준 / 카드 구매하기 / 11052번 / Python (0) | 2025.05.11 |
| 백준 / 테트로미노 / 14500번 / Python (2) | 2025.05.09 |
| 백준 / 다리 만들기 2 / 17472번 / Python (0) | 2025.05.07 |