aboutsummaryrefslogtreecommitdiff
path: root/execs/Day01.hs
blob: 4a10259b18afeba425da0038f74c41c1c72ffa60 (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