diff options
| author | Orfeas <38209077+0xfea5@users.noreply.github.com> | 2025-08-24 01:59:47 +0300 |
|---|---|---|
| committer | Orfeas <38209077+0xfea5@users.noreply.github.com> | 2025-08-24 01:59:47 +0300 |
| commit | 660d34a89cd89098cd3ebb5cbf11d63597d85655 (patch) | |
| tree | b56207481086eab912785d9b56271e4e3f20fcd9 | |
| parent | Add .gitignore (diff) | |
| download | aoc24-660d34a89cd89098cd3ebb5cbf11d63597d85655.tar.gz aoc24-660d34a89cd89098cd3ebb5cbf11d63597d85655.zip | |
Add day initialization script
| -rwxr-xr-x | init.sh | 23 |
1 files changed, 23 insertions, 0 deletions
| @@ -0,0 +1,23 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | year=2024 | ||
| 4 | |||
| 5 | if [ ! $# -eq 1 ] | ||
| 6 | then | ||
| 7 | echo "Usage: $0 <d>" | ||
| 8 | exit 1 | ||
| 9 | fi | ||
| 10 | |||
| 11 | day=$1 | ||
| 12 | cookiefile=${3:-'./cookie'} | ||
| 13 | dir=$(printf "day%02d" $day) | ||
| 14 | |||
| 15 | echo "Initializing directory $dir/" | ||
| 16 | mkdir -p $dir | ||
| 17 | |||
| 18 | advent_session=$(cat $cookiefile 2> /dev/null) && | ||
| 19 | echo "Downloading input ..." && | ||
| 20 | curl "https://adventofcode.com/$year/day/$day/input" \ | ||
| 21 | -H "Cookie: session=$advent_session" > $dir/input.txt | ||
| 22 | |||
| 23 | exit 0 | ||
