[hs] Switch to new day system

This commit is contained in:
Joscha 2020-12-03 00:40:20 +00:00
parent 3b0ea44036
commit b87c8e4555
4 changed files with 35 additions and 39 deletions

View file

@ -1,32 +0,0 @@
module Aoc.Y2020.A01
( solve202001
) where
import Control.Monad
findPair :: [Integer] -> (Integer, Integer)
findPair l = head $ do
a <- l
b <- l
guard $ a + b == 2020
pure (a, b)
findTriple :: [Integer] -> (Integer, Integer, Integer)
findTriple l = head $ do
a <- l
b <- l
c <- l
guard $ a + b + c == 2020
pure (a, b, c)
solve202001 :: FilePath -> IO ()
solve202001 f = do
values <- map read . lines <$> readFile f
putStrLn ">> Part 1"
let (x1, x2) = findPair values
putStrLn $ show x1 ++ " * " ++ show x2 ++ " = " ++ show (x1 * x2)
let (y1, y2, y3) = findTriple values
putStrLn ">> Part 2"
putStrLn $ show y1 ++ " * " ++ show y2 ++ " * " ++ show y3 ++ " = " ++ show (y1 * y2 * y3)