-
Notifications
You must be signed in to change notification settings - Fork 0
/
day-x.py
61 lines (46 loc) · 1.28 KB
/
day-x.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
54
55
56
57
58
59
60
61
import re
import sys
# Get the day from the filename e.g. day-1.py
DAY = re.match(r"day\-(\d+)\.py", sys.argv[0]).groups()[0]
def part_1(path):
"""Part 1/Star 1"""
# Open the file
with open(f"{path}/day-{DAY}.txt", "r") as f:
values = [line.strip() for line in f.readlines()]
# TODO: Complete the task
answer = 0
# Print out the response
print(f"Task 1 Answer: {answer}")
def part_2(path):
"""Part 2/Star 2"""
# Open the file
with open(f"{path}/day-{DAY}.txt", "r") as f:
values = [line.strip() for line in f.readlines()]
# TODO: Complete the task
answer = 0
# Print out the response
print(f"Task 2 Answer: {answer}")
if __name__ == "__main__":
"""
Run using e.g.
`python day-1.py -test`
`python day-1.py`
`python day-1.py -test -2`
`python day-1.py -2`
`python day-1.py -test -both`
`python day-1.py -both`
"""
# Identify the folder that the input is in
test = "-test" in sys.argv
if test:
path = "input-tests"
else:
path = "inputs"
# Identify which one to run - 1 is default
if "-2" in sys.argv:
part_2(path)
elif "-both" in sys.argv:
part_1(path)
part_2(path)
else:
part_1(path)