We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ad2004 commit 2839b28Copy full SHA for 2839b28
VERSION
@@ -1 +1 @@
1
-2024.5.1.0
+2024.5.1.1
src/AdventOfCode/Year2024/Day01.hs
@@ -12,13 +12,12 @@ main :: IO ()
12
main = $(defaultMain)
13
14
partOne :: (Num a, Ord a) => ([a], [a]) -> a
15
-partOne (xs, ys) = sum $ zipWith ((abs .) . (-)) (sort xs) (sort ys)
+partOne (xs, ys) = sumOn' abs $ zipWith subtract (sort xs) (sort ys)
16
17
partTwo :: (Num a, Ord a) => ([a], [a]) -> a
18
partTwo (xs, ys) = sumOn' go xs
19
where
20
- go x = x * fromIntegral (Map.findWithDefault 0 x freqs)
21
- freqs = frequencies ys
+ go x = x * fromIntegral (Map.findWithDefault 0 x (frequencies ys))
22
23
getInput :: IO ([Integer], [Integer])
24
getInput =
0 commit comments