#!/usr/bin/env sh get(){ curl -s --cookie "session=$1" "$2" | perl -pe 'chomp if eof' > "$3" } if [ -n "${2+x}" ] && [ -n "${3+x}" ]; then year="20$2" day="$3" if [ "$day" -lt 10 ]; then d="0$day" else d="$day" fi url="https://adventofcode.com/$year/day/$day/input" get "$1" "$url" "input/$year/$d" exit 0 fi #rm -rf input for year in {2015..2024}; do mkdir -p input/"$year" for day in {1..25}; do if [[ day -lt 10 ]]; then d="0$day" else d="$day" fi url="https://adventofcode.com/$year/day/$day/input" get "$1" "$url" "input/$year/$d" done touch "input/$year/test" done