AoC/2020/day01/day01.hs

14 lines
284 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"
2020-12-01 12:03:49 +01:00
print $ day1 2 input
print $ day1 3 input
2020-12-01 06:26:32 +01:00
2020-12-01 12:03:49 +01:00
day1 :: Int -> [Int] -> Int
day1 =
fmap (snd . head . filter ((== 2020) . fst) . map (sum &&& product)) .
replicateM