diff options
Diffstat (limited to 'execs')
-rw-r--r-- | execs/Day01.hs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/execs/Day01.hs b/execs/Day01.hs new file mode 100644 index 0000000..4a10259 --- /dev/null +++ b/execs/Day01.hs | |||
@@ -0,0 +1,22 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Monad | ||
4 | |||
5 | main :: IO () | ||
6 | main = do | ||
7 | n <- map read . lines <$> readFile "input/01" | ||
8 | print . head $ ans1 n | ||
9 | print . head $ ans2 n | ||
10 | |||
11 | ans1 l = do | ||
12 | a <- l | ||
13 | b <- l | ||
14 | guard $ a + b == 2020 | ||
15 | return $ a * b | ||
16 | |||
17 | ans2 l = do | ||
18 | a <- l | ||
19 | b <- l | ||
20 | c <- l | ||
21 | guard $ a + b + c == 2020 | ||
22 | return $ a * b * c | ||