Day 1: more golf

This commit is contained in:
shu 2020-12-01 12:03:49 +01:00
parent 36ccd6f974
commit 779261f107

@ -4,10 +4,10 @@ import Control.Monad
main :: IO ()
main = do
input <- map read . lines <$> readFile "input"
print $ day1 input 2
print $ day1 input 3
print $ day1 2 input
print $ day1 3 input
day1 :: [Int] -> Int -> Int
day1 input n =
snd . head . filter ((== 2020) . fst) $
map (sum &&& product) $ replicateM n input
day1 :: Int -> [Int] -> Int
day1 =
fmap (snd . head . filter ((== 2020) . fst) . map (sum &&& product)) .
replicateM