aboutsummaryrefslogtreecommitdiff
path: root/execs/Day01.hs
blob: 2f50b2787afd0bba9cece5b5fa18384eb6a60dc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Main where

import           Control.Monad

main :: IO ()
main = do
    n <- map read . lines <$> readFile "input/01"
    print . head $ ans1 n
    print . head $ ans2 n

ans1 l = do
    a <- l
    b <- l
    guard $ a + b == 2020
    return $ a * b

ans2 l = do
    a <- l
    b <- l
    c <- l
    guard $ a + b + c == 2020
    return $ a * b * c