-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_problem.sh
executable file
·58 lines (43 loc) · 1.01 KB
/
new_problem.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
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
if [[ $# -lt 2 ]]; then
echo "Usage: $0 <year> <day num>"
exit 1
fi
year=$1
day=$2
padded_day=$(printf "%02d" "${day}")
path="y${year}/problem${padded_day}"
pkg="y${year}.problem${padded_day}"
mkdir -p "${path}"
touch "${path}/input"
#TODO: needs auth
#wget -O "${path}/input" "https://adventofcode.com/${year}/day/${day}/input"
touch "${path}/input"
touch "${path}/__init__.py"
cat <<END >"${path}/__init__.py"
from typing import *
def part1(inp: str):
return 0
def part2(inp: str):
return 0
END
cat <<END >"${path}/__main__.py"
from ${pkg} import *
if __name__ == "__main__":
with open("$path/input") as f:
inp = f.read(-1).strip()
print("part 1:", part1(inp))
print("part 2:", part2(inp))
END
cat <<END >"${path}/test_problem${padded_day}.py"
from $pkg import *
example = """"""
def test_part1_example():
# TODO: populate
assert part1(example) == 0
def test_part2_example():
# TODO: populate
assert part2(example) == 0
END