From e33be020ef79629b554b4ac2f57fe336382a3baf Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 2 Dec 2024 00:04:51 +0100 Subject: 1: optimise (as if it's necessary) --- 2024/1.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] -- cgit v1.2.3-70-g09d2