diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-12-02 00:04:51 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-12-02 00:04:51 +0100 |
commit | e33be020ef79629b554b4ac2f57fe336382a3baf (patch) | |
tree | 9b8f21659ebe2bcb7ab7a410d2ca99a9e19e9e18 | |
parent | ec6e98f6aed5684131a0fd42ed1d47864eb821aa (diff) |
1: optimise (as if it's necessary)
-rw-r--r-- | 2024/1.hs | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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] |