From 301d93157c16dc93fd6a2c854ca87a1780dd6622 Mon Sep 17 00:00:00 2001 From: Kharec Date: Fri, 28 Nov 2025 17:51:51 +0100 Subject: [PATCH] feat: add part one solution --- internal/2015/DayThree/code.go | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 internal/2015/DayThree/code.go diff --git a/internal/2015/DayThree/code.go b/internal/2015/DayThree/code.go new file mode 100644 index 0000000..966eb97 --- /dev/null +++ b/internal/2015/DayThree/code.go @@ -0,0 +1,43 @@ +package daythree + +import ( + "advent-of-code/internal/registry" + "os" +) + +type coordinates struct { + x, y int +} + +func init() { + registry.Register("2015D3", ParseInput, PartOne, PartTwo) +} + +func ParseInput(filepath string) string { + content, _ := os.ReadFile(filepath) + return string(content) +} + +func PartOne(data string) int { + houses := make(map[coordinates]int) + x, y := 0, 0 + houses[coordinates{x, y}] = 1 + for _, direction := range data { + switch direction { + case '>': + x++ + case '<': + x-- + case '^': + y++ + case 'v': + y-- + } + houses[coordinates{x, y}]++ + } + return len(houses) +} + +func PartTwo(data string) int { + return 0 +}