From: Neil Smith Date: Tue, 24 Dec 2024 09:40:03 +0000 (+0000) Subject: Tidying X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=a6801d95df9cc042f48c7d5bbde9e8a5e858a8d0;p=advent-of-code-24.git Tidying --- 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