adventofcode2020/2020/1.hs
2020-12-02 14:06:06 +02:00

5 lines
269 B
Haskell

main = readFile "1" >>= putStrLn . show . f . g . map (\x -> read x :: Integer) . lines
where f (x:_, y:_) | x + y == 2020 = x * y
f (x:xs, _:ys) = f (x:xs, ys)
f (_:xs, []) = f $ g xs
g (x:xs) = (x:xs, xs)