Add generate_days script

- Add generate_days script to generate templated files for an advent of
  code year.
- Optimize the fetch.sh script (remove awk usage)
This commit is contained in:
Thraix
2026-07-25 19:57:11 +02:00
parent 6a3a1c9dc1
commit a9ac1c2c98
5 changed files with 59 additions and 8 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
#/bin/sh
#!/bin/sh
if [ ! -e cookies.txt ]; then
echo "No cookies.txt file exists"
@@ -8,11 +8,11 @@ fi
list=$(find -name "Day*.cpp" | awk -F '/' '{print $3 "/" $4}' | awk -F '.' '{print $1}' | sed 's/Day//g' | sort)
for item in $list; do
year=$(echo $item | awk -F '/' '{print $1}')
day=$(echo $item | awk -F '/' '{print $2}')
year=${item%/*} # remove everything before /
day=${item#*/} # remove everything after /
dir="res/$year/day$day/input.txt"
if [ ! -e $dir ]; then
webitem=$(echo $day | sed 's/^0//g')
webitem=${day#0}
echo "Fetching $dir"
tmp_file=$(mktemp)
HTTP_CODE=$(curl -s -w "%{http_code}" -o "$tmp_file" --cookie cookies.txt https://adventofcode.com/$year/day/$webitem/input)