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
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
leading_zero() {
printf '%02d\n' $1
}
if [ $# -le 1 ]; then
echo "year and amount of days arguments not passed"
exit 1
fi
mkdir 'src/'$1
mkdir 'res/'$1
for i in $(seq 1 $2); do
i2=$(leading_zero $i)
cat Template.cpp |
sed 's/$1/'$1'/g' |
sed 's/$2/'$i2'/g' > \
'src/'$1'/Day'$i2'.cpp'
res_dir='res/'$1'/day'$i2'/'
mkdir $res_dir
touch $res_dir'/test_input.txt'
done