From d66cd1179d9f448e5496af4750c810a7fc9c6eb7 Mon Sep 17 00:00:00 2001 From: Kharec Date: Mon, 1 Dec 2025 07:31:15 +0100 Subject: [PATCH] feat: solve P1 using modulo to keep it between boundaries --- internal/2025/DayOne/code.go | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 internal/2025/DayOne/code.go diff --git a/internal/2025/DayOne/code.go b/internal/2025/DayOne/code.go new file mode 100644 index 0000000..cb41e7c --- /dev/null +++ b/internal/2025/DayOne/code.go @@ -0,0 +1,43 @@ +package dayone + +import ( + "advent-of-code/internal/registry" + "os" + "strconv" + "strings" +) + +func init() { + registry.Register("2025D1", ParseInput, PartOne, PartTwo) +} + +func ParseInput(filepath string) []string { + content, _ := os.ReadFile(filepath) + return strings.Split(string(content), "\n") +} + +func PartOne(data []string) int { + position := 50 + count := 0 + + for _, rotation := range data { + direction := rotation[0] + distance, _ := strconv.Atoi(rotation[1:]) + + if direction == 'L' { + position = (position - distance + 100) % 100 + } else { + position = (position + distance) % 100 + } + + if position == 0 { + count++ + } + } + + return count +} + +func PartTwo(data []string) int { + return 0 +}