aoc/cmd/main.go

78 lines
1.2 KiB
Go
Raw Permalink Normal View History

2024-07-24 14:29:59 +00:00
package main
import (
"aoc/aoc2015"
"aoc/aoc2016"
"aoc/aoc2017"
"aoc/aoc2018"
"aoc/aoc2019"
"aoc/aoc2020"
"aoc/aoc2021"
"aoc/aoc2022"
"aoc/aoc2023"
2024-07-24 18:03:39 +00:00
"aoc/internal/utility"
2024-07-24 14:29:59 +00:00
"errors"
"fmt"
"strconv"
)
func main() {
var (
2024-07-24 18:03:39 +00:00
adv utility.AdventRunner
2024-07-24 14:29:59 +00:00
input string
)
fmt.Print("Enter year (15-23): ")
_, err := fmt.Scanln(&input)
2024-07-24 18:03:39 +00:00
utility.E(err)
2024-07-24 14:29:59 +00:00
year, err := strconv.Atoi(input)
2024-07-24 18:03:39 +00:00
utility.E(err)
2024-07-24 14:29:59 +00:00
if year >= 2015 && year <= 2023 {
year -= 2000
}
if year < 15 || year > 23 {
2024-07-24 18:03:39 +00:00
utility.E(errors.New("year out of range"))
2024-07-24 14:29:59 +00:00
}
fmt.Print("Enter day (1-25): ")
_, err = fmt.Scanln(&input)
2024-07-24 18:03:39 +00:00
utility.E(err)
2024-07-24 14:29:59 +00:00
day, err := strconv.Atoi(input)
2024-07-24 18:03:39 +00:00
utility.E(err)
2024-07-24 14:29:59 +00:00
if day < 1 || day > 25 {
2024-07-24 18:03:39 +00:00
utility.E(errors.New("day out of range"))
2024-07-24 14:29:59 +00:00
}
switch year {
case 15:
adv = aoc2015.Runner{}
case 16:
adv = aoc2016.Runner{}
case 17:
adv = aoc2017.Runner{}
case 18:
adv = aoc2018.Runner{}
case 19:
adv = aoc2019.Runner{}
case 20:
adv = aoc2020.Runner{}
case 21:
adv = aoc2021.Runner{}
case 22:
adv = aoc2022.Runner{}
case 23:
adv = aoc2023.Runner{}
default:
2024-07-24 18:03:39 +00:00
utility.E(errors.New("unknown year in switch, should never hit this"))
2024-07-24 14:29:59 +00:00
}
if adv != nil {
adv.Run(day)
}
}