diff --git a/AoC_2025/Day07.cs b/AoC_2025/Day07.cs index ba31956..55d63d3 100644 --- a/AoC_2025/Day07.cs +++ b/AoC_2025/Day07.cs @@ -59,21 +59,23 @@ public class Day07 : IPuzzleSolver if (grid[current.x][current.y] == '^') { splittersHit++; - var nextLeft = (current.x, current.y - 1); - var nextRight = (current.x, current.y + 1); - if (visited.Add(nextLeft)) seen.Enqueue(nextLeft); - if (visited.Add(nextRight)) seen.Enqueue(nextRight); + CheckAndEnqueueIfNotVisited((current.x, current.y - 1)); + CheckAndEnqueueIfNotVisited((current.x, current.y + 1)); } else { - var next = (current.x + 1, current.y); - if (visited.Add(next)) seen.Enqueue(next); + CheckAndEnqueueIfNotVisited((current.x + 1, current.y)); } } return splittersHit; + + void CheckAndEnqueueIfNotVisited(Coordinate coordinate) + { + if (visited.Add(coordinate)) seen.Enqueue(coordinate); + } } - + private Dictionary GetNodesTraversedWitTimelineCount(string[] grid, Coordinate current, HashSet path, Dictionary nodeCountVisited) { if (current.x >= grid.Length || nodeCountVisited.ContainsKey(current))