From 1f5b8247a9ca6a09ac677cae41fc85198406f1c5 Mon Sep 17 00:00:00 2001 From: Kharec Date: Fri, 28 Nov 2025 16:47:56 +0100 Subject: [PATCH] feat: add p2 solution --- internal/2015/DayTwo/code.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/2015/DayTwo/code.go b/internal/2015/DayTwo/code.go index a7d2ddd..33e4282 100644 --- a/internal/2015/DayTwo/code.go +++ b/internal/2015/DayTwo/code.go @@ -29,5 +29,20 @@ func PartOne(data []string) int { } func PartTwo(data []string) int { - return 0 + 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]) + + smallest := min(length, width, height) + middle := length + width + height - smallest - max(length, width, height) + + perimeter := 2 * (smallest + middle) + volume := length * width * height + + total += perimeter + volume + } + return total }