Day6 optimisation
parent
90aa8db5aa
commit
c74ab1cabf
|
@ -235,14 +235,19 @@ namespace Advent24
|
||||||
|
|
||||||
// remove already-checked linear positions from visited
|
// remove already-checked linear positions from visited
|
||||||
// so it only has new positions to add to our uncheckedLinearPositions
|
// 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;
|
previousUncheckedLinearPositionsCount = uncheckedLinearPositions.Count;
|
||||||
|
|
||||||
// update uncheckedLinearPositions to remove firstNonCheckedLinearPosition
|
// update uncheckedLinearPositions to remove firstNonCheckedLinearPosition
|
||||||
// and add newly visisted linear positions
|
// and add newly visisted linear positions
|
||||||
uncheckedLinearPositions.Remove(firstNonCheckedLinearPosition);
|
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)
|
// if (uncheckedLinearPositions.Count > previousUncheckedLinearPositionsCount)
|
||||||
// Console.WriteLine("(change) uncheckedLinearPositions.Count = {0:d}", uncheckedLinearPositions.Count - previousUncheckedLinearPositionsCount);
|
// Console.WriteLine("(change) uncheckedLinearPositions.Count = {0:d}", uncheckedLinearPositions.Count - previousUncheckedLinearPositionsCount);
|
||||||
|
|
Loading…
Reference in New Issue