Removed the unnecessary extra zero row
This commit is contained in:
parent
4b23d58e5e
commit
6682bd9757
|
@ -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
|
||||
print $ sum $ foldr ((+) . last) 0 . takeWhile (any (/= 0)) . iterate (zipWith (flip (-)) <*> tail) <$> values
|
|
@ -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
|
||||
print $ sum $ foldr (flip subtract . head) 0 . takeWhile (any (/= 0)) . iterate (zipWith (flip (-)) <*> tail) <$> values
|
Loading…
Reference in New Issue