Initial commit
This commit is contained in:
commit
cf2af11b6b
23 changed files with 3988 additions and 0 deletions
39
gen.sh
Executable file
39
gen.sh
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
Y="$1"; shift
|
||||
if [ -z "$Y" ]; then
|
||||
Y="$(date +%Y)"
|
||||
fi
|
||||
|
||||
fday="$1"; shift
|
||||
tday="$1"; shift
|
||||
|
||||
if [ -z "$fday" ]; then
|
||||
fday=1
|
||||
tday=25
|
||||
fi
|
||||
if [ -z "$tday" ]; then
|
||||
tday="${fday}"
|
||||
fi
|
||||
|
||||
days=($(seq $fday $tday))
|
||||
|
||||
if ! grep -q "Y${Y}" src/AoC/Year.hs; then
|
||||
sed -i -e "s/\(\(\s\+\)= Y0000\)/\1\n\2| Y${Y}/" src/AoC/Year.hs
|
||||
fi
|
||||
|
||||
mkdir -p "src/AoC/Y${Y}"
|
||||
if ! test -f "src/AoC/Y${Y}.hs"; then
|
||||
sed -e "s/Y0000/Y${Y}/g" template/Y0000.hs > "src/AoC/Y${Y}.hs"
|
||||
fi
|
||||
|
||||
for d in "${days[@]}"; do
|
||||
d=$(printf "%02d" "$d")
|
||||
mkdir -p "data/Y${Y}/D${d}"
|
||||
touch "data/Y${Y}/D${d}/riddle"
|
||||
touch "data/Y${Y}/D${d}/result"
|
||||
|
||||
if ! test -f "src/AoC/Y${Y}/D${d}.hs"; then
|
||||
sed -e "s/Y0000/Y${Y}/g" -e "s/D00/D${d}/g" template/D00.hs > "src/AoC/Y${Y}/D${d}.hs"
|
||||
fi
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue