From ff4b7b281cd2ce97c027b65994fa33a62b294841 Mon Sep 17 00:00:00 2001 From: Kharec Date: Fri, 28 Nov 2025 17:59:03 +0100 Subject: [PATCH] feat: add p2 solution --- internal/2015/DayThree/code.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/internal/2015/DayThree/code.go b/internal/2015/DayThree/code.go index 966eb97..b1a4190 100644 --- a/internal/2015/DayThree/code.go +++ b/internal/2015/DayThree/code.go @@ -39,5 +39,30 @@ func PartOne(data string) int { } func PartTwo(data string) int { - return 0 + houses := make(map[coordinates]int) + santaX, santaY := 0, 0 + robotX, robotY := 0, 0 + houses[coordinates{0, 0}] = 2 + + for idx, direction := range data { + var x, y *int + if idx%2 == 0 { + x, y = &santaX, &santaY + } else { + x, y = &robotX, &robotY + } + + switch direction { + case '>': + *x++ + case '<': + *x-- + case '^': + *y++ + case 'v': + *y-- + } + houses[coordinates{*x, *y}]++ + } + return len(houses) }