From c74ab1cabf4d734a5cd6bcbf25da461a41fdc137 Mon Sep 17 00:00:00 2001 From: login000 Date: Tue, 10 Dec 2024 15:49:26 +1030 Subject: [PATCH] Day6 optimisation --- Advent24/Day6.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Advent24/Day6.cs b/Advent24/Day6.cs index 4b54a47..bbfa106 100644 --- a/Advent24/Day6.cs +++ b/Advent24/Day6.cs @@ -235,14 +235,19 @@ namespace Advent24 // remove already-checked linear positions from visited // so it only has new positions to add to our uncheckedLinearPositions - visited.ExceptWith(checkedLinearPositions); + // This line isn't required because we're only adding one additional obstacle, which + // will only affect the original path (which we're already checking) + //visited.ExceptWith(checkedLinearPositions); previousUncheckedLinearPositionsCount = uncheckedLinearPositions.Count; // update uncheckedLinearPositions to remove firstNonCheckedLinearPosition // and add newly visisted linear positions uncheckedLinearPositions.Remove(firstNonCheckedLinearPosition); - uncheckedLinearPositions.UnionWith(visited); + + // This line isn't required because we're only adding one additional obstacle, which + // will only affect the original path (which we're already checking) + //uncheckedLinearPositions.UnionWith(visited); // if (uncheckedLinearPositions.Count > previousUncheckedLinearPositionsCount) // Console.WriteLine("(change) uncheckedLinearPositions.Count = {0:d}", uncheckedLinearPositions.Count - previousUncheckedLinearPositionsCount);