feat: add part one solution

This commit is contained in:
2025-11-28 17:51:51 +01:00
parent 7e0a1e71a7
commit 301d93157c

View File

@@ -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
}