package utils import ( "bufio" "fmt" "io" "os" "strconv" "strings" ) func PanicOnErr(err error) { if err != nil { panic(err) } } func MustAtoi(s string) int { v, err := strconv.Atoi(s) PanicOnErr(err) return v } func Readfile(day int, example bool) string { filename := fmt.Sprintf("input/day%02d.txt", day) if example { filename = fmt.Sprintf("input/day%02d_example.txt", day) } file, err := os.Open(filename) PanicOnErr(err) defer file.Close() reader := bufio.NewReader(file) contents, err := io.ReadAll(reader) PanicOnErr(err) return strings.TrimSuffix(string(contents), "\n") }