From 5513ae83862ed3a5af543576c2a53a9817a8defd Mon Sep 17 00:00:00 2001 From: Kharec Date: Tue, 2 Dec 2025 20:38:20 +0100 Subject: [PATCH] feat: solve part one using basic parsing --- internal/2015/DayEight/code.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/internal/2015/DayEight/code.go b/internal/2015/DayEight/code.go index 2c5e50e..e34033f 100644 --- a/internal/2015/DayEight/code.go +++ b/internal/2015/DayEight/code.go @@ -15,3 +15,33 @@ func ParseInput(filepath string) []string { content, _ := os.ReadFile(filepath) return strings.Split(string(content), "\n") } + +func PartOne(data []string) int { + result := 0 + for _, line := range data { + codeLength := len(line) + memoryLength := 0 + for idx := 1; idx < len(line)-1; idx++ { + if line[idx] == '\\' && idx+1 < len(line)-1 { + switch line[idx+1] { + case '\\', '"': + memoryLength++ + idx++ + case 'x': + if idx+3 < len(line)-1 { + memoryLength++ + idx += 3 + } + } + } else { + memoryLength++ + } + } + result += codeLength - memoryLength + } + return result +} + +func PartTwo(data []string) int { + return 0 +}