summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-12-02 00:04:51 +0100
committerTom Smeding <tom@tomsmeding.com>2024-12-02 00:04:51 +0100
commite33be020ef79629b554b4ac2f57fe336382a3baf (patch)
tree9b8f21659ebe2bcb7ab7a410d2ca99a9e19e9e18
parentec6e98f6aed5684131a0fd42ed1d47864eb821aa (diff)
1: optimise (as if it's necessary)
-rw-r--r--2024/1.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/2024/1.hs b/2024/1.hs
index c3871d6..3301ceb 100644
--- a/2024/1.hs
+++ b/2024/1.hs
@@ -9,5 +9,5 @@ main = do
. map (\l -> let [x,y] = words l in (read @Int x, read y))
. lines <$> getContents
print $ sum (zipWith (\x y -> abs (x - y)) a b)
- let hist = Map.fromListWith (+) (map (,1 :: Int) b)
+ let hist = Map.fromAscListWith (+) (map (,1 :: Int) b)
print $ sum [n * Map.findWithDefault 0 n hist | n <- a]