16
Day1/Lib.hs
Normal file
16
Day1/Lib.hs
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
)
|
||||
[[]]
|
Reference in New Issue
Block a user