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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user