From 2d6c89d7c9dc2c44cdd1cd4287eb805aefeedca9 Mon Sep 17 00:00:00 2001 From: Kharec Date: Fri, 28 Nov 2025 16:45:04 +0100 Subject: [PATCH] feat: add solution for p1 --- internal/2015/DayTwo/code.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 internal/2015/DayTwo/code.go diff --git a/internal/2015/DayTwo/code.go b/internal/2015/DayTwo/code.go new file mode 100644 index 0000000..a7d2ddd --- /dev/null +++ b/internal/2015/DayTwo/code.go @@ -0,0 +1,33 @@ +package daytwo + +import ( + "advent-of-code/internal/registry" + "os" + "strconv" + "strings" +) + +func init() { + registry.Register("2015D2", ParseInput, PartOne, PartTwo) +} + +func ParseInput(filepath string) []string { + content, _ := os.ReadFile(filepath) + return strings.Split(string(content), "\n") +} + +func PartOne(data []string) int { + total := 0 + for _, line := range data { + parts := strings.Split(line, "x") + length, _ := strconv.Atoi(parts[0]) + width, _ := strconv.Atoi(parts[1]) + height, _ := strconv.Atoi(parts[2]) + total += 2*length*width + 2*width*height + 2*height*length + min(length*width, width*height, height*length) + } + return total +} + +func PartTwo(data []string) int { + return 0 +}