-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkday.sh
executable file
·65 lines (47 loc) · 1.25 KB
/
mkday.sh
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
62
63
64
65
#!/usr/bin/env zsh
if [[ $# -lt 2 ]]; then
echo "Example usage: ./mkday.sh 2020 01"
exit 1
fi
pyfile="src/$1/$2.py"
touch $pyfile
chmod a+x $pyfile
cat > $pyfile <<EOL
#!/usr/bin/env python
"""https://adventofcode.com/$1/day/$2."""
import sys
import aocd
def p1(lines):
pass
def p2(lines):
pass
if __name__ == "__main__":
year, day, path = sys.argv[1:]
i = 1
while True:
example_path = path + f"/example-{i}.txt"
if not os.path.exists(example_path):
break
with open(example_path) as f:
lines = [list(l) for l in f.read().splitlines()]
i += 1
p1_theirs = None
p2_theirs = None
p1_mine = p1(lines)
p2_mine = p2(lines)
print("Examples:")
print(f"Part a (theirs): {p1_theirs}")
print(f"Part b (theirs): {p2_theirs}")
print()
print(f"Part a (mine): {p1_mine}")
print(f"Part b (mine): {p2_mine}")
print()
print()
with open(path + "/input.txt") as f:
lines = [list(l) for l in f.read().splitlines()]
print("Real:")
if p1_theirs == p1_mine:
aocd.submit(p1(lines), part="a", day=int(day), year=int(year))
if p2_theirs == p2_mine:
aocd.submit(p2(lines), part="b", day=int(day), year=int(year))
EOL