Day6 optimisation

main
login000 2024-12-10 15:49:26 +10:30
parent 90aa8db5aa
commit c74ab1cabf
1 changed files with 7 additions and 2 deletions

View File

@ -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);