From 9de558024f29cf832c2a5991771e5f19a998ba67 Mon Sep 17 00:00:00 2001 From: Kharec Date: Tue, 3 Feb 2026 16:08:30 +0100 Subject: [PATCH] feat: solve part one using dfs approach --- internal/2025/DayEleven/code.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/internal/2025/DayEleven/code.go b/internal/2025/DayEleven/code.go index 4ea2613..029c1da 100644 --- a/internal/2025/DayEleven/code.go +++ b/internal/2025/DayEleven/code.go @@ -17,7 +17,27 @@ func ParseInput(filepath string) []string { } func PartOne(data []string) int { - return 0 + graph := make(map[string][]string) + + for _, line := range data { + device, outputsStr, _ := strings.Cut(line, ": ") + graph[device] = strings.Fields(outputsStr) + } + + var countPaths func(string) int + countPaths = func(node string) int { + if node == "out" { + return 1 + } + + count := 0 + for _, neighbor := range graph[node] { + count += countPaths(neighbor) + } + return count + } + + return countPaths("you") } func PartTwo(data []string) int {