From 2725c523ae3627cccd10650c69d8026e7a2f1d4b Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 5 Mar 2023 23:39:47 +0100 Subject: 2022-01 in haskell --- 2022/01/first.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 2022/01/first.hs (limited to '2022/01/first.hs') diff --git a/2022/01/first.hs b/2022/01/first.hs new file mode 100644 index 0000000..300ca7d --- /dev/null +++ b/2022/01/first.hs @@ -0,0 +1,13 @@ +-- requires cabal install --lib split +module Main where + +import Data.List (sort) +import Data.List.Split (splitOn) + +parseAndSum :: String -> [Int] +parseAndSum = map (sum . map read . lines) . splitOn "\n\n" + +main :: IO () +main = do + input <- readFile "input" + print . head . reverse . sort $ parseAndSum input -- cgit v1.2.3