-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_year.py
45 lines (31 loc) · 1010 Bytes
/
setup_year.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
import argparse
import os
import sys
def main(year):
path = os.getcwd()
year_path = f"{path}/{year}"
os.mkdir(year_path)
os.chdir(year_path)
for day in range(1, 25):
day_path = f"{path}/{year}/{day}/"
os.mkdir(day_path)
os.chdir(day_path)
test_cases = """cases = [
{'level': 1, 'input': None, 'output': None},
]"""
solution = """from aoc_utils import aoc_utils
from tests import cases
def answer(problem_input, level, test=False):
return 0
aoc_utils.run(answer, cases)
"""
with open("solution.py", "w") as s:
s.write(solution)
with open("tests.py", "w") as tc:
tc.write(test_cases)
os.chdir(year_path)
if __name__ == '__main__':
cl = argparse.ArgumentParser(description="This script generates python templates for each AoC day.")
cl.add_argument("--year", required=True, help="the year of AoC we are working with")
args = cl.parse_args()
sys.exit(main(args.year))