#!/usr/bin/env sh usage="usage: check " year=${1?$usage} day=${2?$usage} lang=${3?$usage} input=${4?$usage} # get directory of this script script=$(readlink -f "$0") script_path=$(dirname "$script") # find aoc and data paths aoc_path=$script_path/$year/$day data_path="$aoc_path/data/$input.txt" case $lang in "python") cmd="uv run --directory $aoc_path/python main.py" ;; "rust") cmd="cargo run --manifest-path $aoc_path/rust/Cargo.toml --" ;; "rustc") cmd="cargo run --release --manifest-path $aoc_path/rust/Cargo.toml --" ;; "*") echo "unknown lang: $lang" exit 1 ;; esac result=$(cat $data_path | $cmd) diff=$(echo "$result" | diff $aoc_path/data/$4.ans -) code=$? [ $code -eq 0 ] && echo Solved with $lang! || echo "$diff" echo "\n---stdout---" echo "$result" exit $code