Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 28, 2023
1 parent b55b15f commit d182250
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion solutions/src/2023/05.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion solutions/src/2023/06.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Distance: 9 40 200
71503
-}
module Main where
module Main (main) where

import Advent (format, binSearchLargest)

Expand Down
11 changes: 5 additions & 6 deletions solutions/src/2023/15.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)]
2 changes: 1 addition & 1 deletion solutions/src/2023/17.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d182250

Please sign in to comment.