diff --git a/AoC_2025/Day11.cs b/AoC_2025/Day11.cs index 2df206e..8cd75e5 100644 --- a/AoC_2025/Day11.cs +++ b/AoC_2025/Day11.cs @@ -39,9 +39,10 @@ public class Day11 : IPuzzleSolver { if (from == to) return 1; if (memory.TryGetValue((from, to), out var res)) return res; + if (!paths.TryGetValue(from, out var pathsToCheck)) return 0; var totalAmount = 0L; - foreach (var path in paths[from]) + foreach (var path in pathsToCheck) { var amount = GetAmountPaths(path, to, paths, memory); memory[(path, to)] = amount; @@ -59,9 +60,10 @@ public class Day11 : IPuzzleSolver through.Remove(from); if (from == to) return through.Count == 0 ? 1 : 0; if (memory.TryGetValue((from, to), out var res) && res.Item2.SetEquals(through)) return res.Item1; + if (!paths.TryGetValue(from, out var pathsToCheck)) return 0; var totalAmount = 0L; - foreach (var path in paths[from]) + foreach (var path in pathsToCheck) { var amount = GetAmountPathsThrough(path, to, [..through], paths, memory); memory[(path, to)] = (amount, through);