From d182250f31951d4abcb250a3c701a1eacd01f1a6 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Wed, 27 Dec 2023 23:04:26 -0600 Subject: [PATCH] cleanup --- solutions/src/2023/05.hs | 2 +- solutions/src/2023/06.hs | 2 +- solutions/src/2023/15.hs | 11 +++++------ solutions/src/2023/17.hs | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/solutions/src/2023/05.hs b/solutions/src/2023/05.hs index e8225c6..dc70366 100644 --- a/solutions/src/2023/05.hs +++ b/solutions/src/2023/05.hs @@ -46,7 +46,7 @@ ranges and find the lowest bound of the output intervals. 46 -} -module Main where +module Main (main) where import Advent (format, chunks) import Advent.Box (intersectBox, Box', Box(..), subtractBox') diff --git a/solutions/src/2023/06.hs b/solutions/src/2023/06.hs index 0ccbae9..e01e626 100644 --- a/solutions/src/2023/06.hs +++ b/solutions/src/2023/06.hs @@ -23,7 +23,7 @@ Distance: 9 40 200 71503 -} -module Main where +module Main (main) where import Advent (format, binSearchLargest) diff --git a/solutions/src/2023/15.hs b/solutions/src/2023/15.hs index 29fabea..03551e5 100644 --- a/solutions/src/2023/15.hs +++ b/solutions/src/2023/15.hs @@ -36,9 +36,8 @@ main = let boxes = accumArray updateBox [] (0, 255) [(hash lbl, (lbl, cmd)) | (_, (lbl, cmd)) <- input] - print (sum [ (1+box) * i * len - | (box, xs) <- assocs boxes - , (i, (_, len)) <- zip [1..] xs]) + print (sum [ (1 + box) * sum (zipWith (*) [1..] (map snd xs)) + | (box, xs) <- assocs boxes]) -- | Run the HASH algorithm on an input string. hash :: String -> Int @@ -52,6 +51,6 @@ updateBox :: updateBox prev (lbl, Nothing) = filter ((lbl /=) . fst) prev updateBox prev (lbl, Just n ) = go prev where - go ((k,_) : xs) | lbl == k = (lbl, n) : xs - go (x : xs) = x : go xs - go [] = [(lbl, n)] + go ((k, _) : xs) | lbl == k = (lbl, n) : xs + go (x : xs) = x : go xs + go [] = [(lbl, n)] diff --git a/solutions/src/2023/17.hs b/solutions/src/2023/17.hs index cfd112f..f3645c1 100644 --- a/solutions/src/2023/17.hs +++ b/solutions/src/2023/17.hs @@ -49,7 +49,7 @@ queue at the same time for each starting point. 71 -} -module Main where +module Main (main) where import Advent (getInputArray, arrIx) import Advent.Coord (east, south, turnLeft, turnRight, Coord)