14 lines
293 B
Haskell
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
|