Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-02 05:33:17 +05:30
commit 5fe3ea5567
6 changed files with 2337 additions and 0 deletions

16
Day1/Lib.hs Normal file
View 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
)
[[]]