From 7de5fa7794580dcbdffbbcc4062165955a63e0e2 Mon Sep 17 00:00:00 2001 From: Kharec Date: Sat, 6 Dec 2025 23:40:20 +0100 Subject: [PATCH] fix: update parsing to avoid doing split in both functions --- internal/2021/DayFour/code.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/2021/DayFour/code.go b/internal/2021/DayFour/code.go index cdb471a..5e9248c 100644 --- a/internal/2021/DayFour/code.go +++ b/internal/2021/DayFour/code.go @@ -14,9 +14,9 @@ func init() { registry.Register("2021D4", ParseInput, PartOne, PartTwo) } -func ParseInput(filepath string) string { +func ParseInput(filepath string) []string { content, _ := os.ReadFile(filepath) - return string(content) + return strings.Split(strings.TrimSpace(string(content)), "\n") } type board struct { @@ -113,8 +113,7 @@ func parseNumbers(line string) []int { return numbers } -func PartOne(input string) int { - lines := strings.Split(strings.TrimSpace(input), "\n") +func PartOne(lines []string) int { numbers := parseNumbers(lines[0]) boards := parseBoards(lines[1:]) @@ -129,6 +128,6 @@ func PartOne(input string) int { return 0 } -func PartTwo(input string) int { +func PartTwo(lines []string) int { return 0 }