We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7fb2e1f commit d6984deCopy full SHA for d6984de
learntosurf/Backtracking/2025-04-19-[BOJ]-#6603-로또.py
@@ -0,0 +1,26 @@
1
+import sys
2
+
3
+def backtrack(S, path, start):
4
+ if len(path) == 6:
5
+ print(' '.join(map(str, path)))
6
+ return
7
+ for i in range(start, len(S)):
8
+ path.append(S[i])
9
+ backtrack(S, path, i + 1)
10
+ path.pop()
11
12
+lines = sys.stdin.read().splitlines()
13
+first_case = True
14
15
+for line in lines:
16
+ if line == '0':
17
+ break
18
19
+ parts = list(map(int, line.strip().split()))
20
+ S = parts[1:]
21
22
+ if not first_case:
23
+ print()
24
+ first_case = False
25
26
+ backtrack(S, [], 0)
0 commit comments