diff options
author | Akshay <[email protected]> | 2020-12-01 13:47:47 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-12-01 13:47:47 +0000 |
commit | cb13d9733b7af2ee7662ffb428cf6e2a11df138a (patch) | |
tree | 2bc3936f28f21223b13ea7a08689ad1a8a0b89b4 /execs | |
parent | caf1e7203ccdbef4a1913e475f50f7a2a80e20d4 (diff) |
ignore cabal stuff
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 | ||