aoc2024/day-18/cmd/cli/main.go

50 lines
1.2 KiB
Go

/********************************************************************************
Advent of Code 2024 - day-18
********************************************************************************/
package main
import (
"embed"
"flag"
"fmt"
"slices"
log "github.com/sirupsen/logrus"
problems "github.com/onyx-and-iris/aoc2024/day-18"
"github.com/onyx-and-iris/aoc2024/day-18/internal/config"
)
//go:embed testdata
var files embed.FS
func main() {
filename := flag.String("f", "input.txt", "input file")
width := flag.Int("w", 71, "graph width")
height := flag.Int("h", 71, "graph height")
numCorruptions := flag.Int("n", 1024, "number of graph corruptions")
loglevel := flag.Int("l", int(log.InfoLevel), "log level")
flag.Parse()
if slices.Contains(log.AllLevels, log.Level(*loglevel)) {
log.SetLevel(log.Level(*loglevel))
}
data, err := files.ReadFile(fmt.Sprintf("testdata/%s", *filename))
if err != nil {
log.Fatal(err)
}
one, two, err := problems.Solve(data, config.Config{
Width: *width,
Height: *height,
NumCorruptions: *numCorruptions,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("solution one: %d\nsolution two: %s\n", one, two)
}