-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaoc.py
53 lines (42 loc) · 1.17 KB
/
aoc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
import argparse
import runpy
from os import scandir, path
from utils.argparse import Formatter, description, epilog
parser = argparse.ArgumentParser(
description=description,
epilog=epilog,
formatter_class=Formatter,
)
parser.add_argument("-d", "--day", help="Run the code for the specified day", type=int)
args = parser.parse_args()
contents = scandir(".")
directories = [
directory.name
for directory in contents
if directory.is_dir() and directory.name.startswith("day-")
]
def run_day(day):
file = path.join(f"day-{day}", "main.py")
if path.exists(file):
print(f"\nResults for Day {day}:")
runpy.run_path(file, run_name="__main__")
else:
print(f"{day} is not a valid option")
print(description)
if args.day:
day = f"{args.day:02}"
run_day(day)
else:
for day in sorted(directories):
run_day(day[-2:])
while True:
prompt = input("\n(C)ontinue, (Q)uit: ").upper()
if prompt not in ("C", "Q"):
continue
else:
break
if prompt == "C":
continue
elif prompt == "Q":
break