add day-04 + benchmarks

This commit is contained in:
2024-12-05 01:31:44 +00:00
parent fca32422e4
commit e7aa98d637
19 changed files with 498 additions and 0 deletions

41
day-04/cmd/cli/main.go Normal file
View File

@@ -0,0 +1,41 @@
/********************************************************************************
Advent of Code 2024 - day-04
********************************************************************************/
package main
import (
"embed"
"flag"
"fmt"
"slices"
log "github.com/sirupsen/logrus"
problems "github.com/onyx-and-iris/aoc2024/day-04"
)
//go:embed testdata
var files embed.FS
func main() {
filename := flag.String("f", "input.txt", "input file")
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)
if err != nil {
log.Fatal(err)
}
fmt.Printf("solution one: %d\nsolution two: %d\n", one, two)
}