From a6801d95df9cc042f48c7d5bbde9e8a5e858a8d0 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Tue, 24 Dec 2024 09:40:03 +0000 Subject: [PATCH] Tidying --- advent21/Main.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/advent21/Main.hs b/advent21/Main.hs index de64172..bdaf08a 100644 --- a/advent21/Main.hs +++ b/advent21/Main.hs @@ -111,7 +111,8 @@ moveCostUsingCache cache level (a, b) = M.findWithDefault (maxBound :: Int) (CacheKey a b level) cache cheapestCostMove :: Button a => Cache -> Int -> (a, a) -> Int -cheapestCostMove cache level (a, b) = minimum $ fmap (sequenceCostUsingCache cache level) stepChoices +cheapestCostMove cache level (a, b) = + minimum $ fmap (sequenceCostUsingCache cache level) stepChoices where stepChoices = moveBetween (a, b) buildCache :: Int -> Cache @@ -121,7 +122,8 @@ extendCache :: Cache -> Int -> Cache extendCache cache level = foldl' go cache allPairs where allPairs = [(a, b) | a <- [R .. A], b <- [R .. A]] - go c (a, b) = M.insert (CacheKey a b level) (cheapestCostMove c (level - 1) (a, b)) c + go c (a, b) = M.insert (CacheKey a b level) + (cheapestCostMove c (level - 1) (a, b)) c cache1 :: Cache cache1 = M.fromList $ fmap go allPairs -- 2.34.1