From c2a087abf76b2a5e0364d373cf1cd55067b0728a Mon Sep 17 00:00:00 2001 From: David Ashby Date: Sun, 12 Dec 2021 13:05:45 -0500 Subject: [PATCH] memorize the double-room check on day two --- 12/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/12/main.go b/12/main.go index 4fda966..0d11243 100644 --- a/12/main.go +++ b/12/main.go @@ -77,7 +77,8 @@ func descend(rooms map[string]room, currentRoom string, path []string, success c wg.Add(1) go func(link string, path []string) { defer wg.Done() - descend(rooms, link, path, success, canVisitSmallRoomTwice) + // in day 2, skip checks once we know we've visited a small room twice + descend(rooms, link, path, success, canVisitSmallRoomTwice && !doubleSmallAlready(newPath)) }(link, newPath) } }