adventOfCode-2022/src/AoC/Day1.hs

14 lines
324 B
Haskell
Raw Normal View History

2022-12-09 21:32:19 +01:00
2022-12-08 11:26:39 +01:00
module AoC.Day1 where
2022-12-13 16:39:09 +01:00
import Data.List (groupBy,sort)
2022-12-09 21:32:19 +01:00
parseInput :: String -> [[Int]]
2022-12-13 16:39:09 +01:00
parseInput = map (map read) . map tail . groupBy (\_l r -> (not $ null r)) . lines
2022-12-08 11:26:39 +01:00
2022-12-13 16:39:09 +01:00
solveA :: String -> Int
2022-12-09 21:32:19 +01:00
solveA = maximum . map sum . parseInput
2022-12-13 16:39:09 +01:00
solveB :: String -> Int
2022-12-09 21:32:19 +01:00
solveB = sum . take 3 . reverse . sort . map sum . parseInput