Files
AoC2022/Day1/Lib.hs
Amneesh Singh 5fe3ea5567 day1
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-02 16:03:00 +05:30

17 lines
324 B
Haskell

module Lib (calories) where
calories :: String -> [Integer]
calories input =
map (sum . map read) $
filter (not . null) $ split "" $ split '\n' input
split :: Eq a => a -> [a] -> [[a]]
split del =
foldr
( \c (x : xs) ->
if c == del
then [] : x : xs
else (c : x) : xs
)
[[]]