AoC/2020/day01/day01.hs
2020-12-01 09:13:22 +01:00

14 lines
293 B
Haskell

import Control.Arrow
import Control.Monad
main :: IO ()
main = do
input <- map read . lines <$> readFile "input"
print $ day1 input 2
print $ day1 input 3
day1 :: [Int] -> Int -> Int
day1 input n =
snd . head . filter ((== 2020) . fst) $
map (sum &&& product) $ replicateM n input