-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaoc
executable file
·38 lines (32 loc) · 910 Bytes
/
aoc
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
#!/bin/zsh
DAY=$1
SESSION=$(cat .session)
if [ -z "$DAY" ]; then
if [ $(date +%m%y) = "1222" ]; then
DAY="day$(date +%d)"
else
DAY=$(ls | grep day | sort -r | head -n 1)
fi
fi
if [ ! -d "$DAY" ]; then
DAY_NUM=$(echo $DAY | sed -nr 's/^day([0-9]{2})$/\1/p')
if [ -z "$DAY_NUM" ]; then
echo "invalid day: '$DAY' should look like 'dayxx' where xx is the day"
exit 1
fi
cp -R day00 "$DAY"
DAY_URL="https://adventofcode.com/2022/day/$DAY_NUM"
echo "created ./$DAY"
if [ ! -z "$SESSION" ]; then
INPUT="$DAY/input.txt"
curl -fsSL --cookie session=$SESSION "$DAY_URL/input" > "$INPUT" && echo "input downloaded successfully"
fi
git add "$DAY"
echo "happy solving $DAY_URL"
exit 0
fi
echo "running $DAY"
echo "-- tests ---"
pipenv run python $DAY/solution.py
echo "-- real deal ---"
pipenv run python -m $DAY