From f9a50e8b4e5baae3f43bf906b079221f56bc2e00 Mon Sep 17 00:00:00 2001 From: Parnic Date: Sat, 24 Dec 2022 15:43:33 -0600 Subject: [PATCH] Small improvement to day 24 This is the best I have been able to do so far without making vec2's x/y no longer readonly (and then having to clean up after myself each time I leave this scope, which can happen in 3 places...) and since it's a relatively simple change (doesn't kill the ergonomics too terribly), I'm gonna roll with it for now. Part 2 110ms -> 75ms. I thought GetOrthogonalNeighbors was as fast as I could make it, but maybe there are better ways to get this same result... --- src/24.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/24.cs b/src/24.cs index 34a730c..81e6397 100644 --- a/src/24.cs +++ b/src/24.cs @@ -218,8 +218,9 @@ internal class Day24 : Day } // queue up all neighbor possibilities - foreach (var n in q.pos.GetOrthogonalNeighbors()) + foreach (var dir in ivec2.FOURWAY) { + var n = q.pos + dir; if (n == dest) { if (q.steps + 1 < minSteps)