AoC/2020/day01/day01.hs

14 lines
293 B
Haskell
Raw Normal View History

2020-12-01 09:13:22 +01:00
import Control.Arrow
import Control.Monad
2020-12-01 06:26:32 +01:00
main :: IO ()
main = do
2020-12-01 09:13:22 +01:00
input <- map read . lines <$> readFile "input"
print $ day1 input 2
print $ day1 input 3
2020-12-01 06:26:32 +01:00
2020-12-01 09:13:22 +01:00
day1 :: [Int] -> Int -> Int
day1 input n =
snd . head . filter ((== 2020) . fst) $
map (sum &&& product) $ replicateM n input