Skip to content

Commit 2839b28

Browse files
committed
refactor(2024.01-haskell): tidy a bit
1 parent 2ad2004 commit 2839b28

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024.5.1.0
1+
2024.5.1.1

src/AdventOfCode/Year2024/Day01.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ main :: IO ()
1212
main = $(defaultMain)
1313

1414
partOne :: (Num a, Ord a) => ([a], [a]) -> a
15-
partOne (xs, ys) = sum $ zipWith ((abs .) . (-)) (sort xs) (sort ys)
15+
partOne (xs, ys) = sumOn' abs $ zipWith subtract (sort xs) (sort ys)
1616

1717
partTwo :: (Num a, Ord a) => ([a], [a]) -> a
1818
partTwo (xs, ys) = sumOn' go xs
1919
where
20-
go x = x * fromIntegral (Map.findWithDefault 0 x freqs)
21-
freqs = frequencies ys
20+
go x = x * fromIntegral (Map.findWithDefault 0 x (frequencies ys))
2221

2322
getInput :: IO ([Integer], [Integer])
2423
getInput =

0 commit comments

Comments
 (0)