aoc/scripts/generator.sh

69 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
mkdir -p include
for year in {2015..2023}; do
yeardir="aoc${year}"
rm -rf "${yeardir}"
mkdir -p "${yeardir}"
tee "${yeardir}/runner.go" <<EOF
package aoc${year}
import "fmt"
type Runner struct{}
func (r Runner) Run(day int) {
switch day {
case 1: day01()
case 2: day02()
case 3: day03()
case 4: day04()
case 5: day05()
case 6: day06()
case 7: day07()
case 8: day08()
case 9: day09()
case 10: day10()
case 11: day11()
case 12: day12()
case 13: day13()
case 14: day14()
case 15: day15()
case 16: day16()
case 17: day17()
case 18: day18()
case 19: day19()
case 20: day20()
case 21: day21()
case 22: day22()
case 23: day23()
case 24: day24()
case 25: day25()
default:
fmt.Println("Unknown day in ${year}: ", day)
}
}
EOF
for day in {1..25}; do
if [[ $day -lt 10 ]]; then
d="0${day}"
else
d="$day"
fi
tee "${yeardir}/day${d}.go" <<EOF
package aoc${year}
import "fmt"
func day${d}() {
//in := input.GetInput("input/${year}/test")
//in := input.GetInput("input/${year}/${d}")
fmt.Println("${year}-${d} is not implemented yet")
}
EOF
done
done