diff --git a/day09a/src/Main.hs b/day09a/src/Main.hs index ac713d3..3f5a233 100644 --- a/day09a/src/Main.hs +++ b/day09a/src/Main.hs @@ -2,9 +2,7 @@ module Main (main) where -import Data.Bifunctor (Bifunctor (second)) - main :: IO () main = do values <- (fmap (read @Integer) . words <$>) . lines <$> getContents - print $ sum $ foldr ((+) . last) 0 . uncurry (++) . second (pure . head) . span (any (/= 0)) . iterate (zipWith (flip (-)) <*> tail) <$> values \ No newline at end of file + print $ sum $ foldr ((+) . last) 0 . takeWhile (any (/= 0)) . iterate (zipWith (flip (-)) <*> tail) <$> values \ No newline at end of file diff --git a/day09b/src/Main.hs b/day09b/src/Main.hs index ccd9182..79eaf05 100644 --- a/day09b/src/Main.hs +++ b/day09b/src/Main.hs @@ -2,9 +2,7 @@ module Main (main) where -import Data.Bifunctor (Bifunctor (second)) - main :: IO () main = do values <- (fmap (read @Integer) . words <$>) . lines <$> getContents - print $ sum $ foldr (flip subtract . head) 0 . uncurry (++) . second (pure . head) . span (any (/= 0)) . iterate (zipWith (flip (-)) <*> tail) <$> values \ No newline at end of file + print $ sum $ foldr (flip subtract . head) 0 . takeWhile (any (/= 0)) . iterate (zipWith (flip (-)) <*> tail) <$> values \ No newline at end of file