advent-of-code/2020/day1/day1.hs

12 lines
368 B
Haskell

{-# LANGUAGE TypeApplications #-}
import Data.List
import Data.Maybe
import Control.Monad
find_n_summing :: (Num a, Eq a) => a -> Int -> [a] -> Maybe [a]
find_n_summing to = (find ((to ==) . sum) .) . replicateM
main = do
nums <- fmap read <$> lines <$> readFile "input.txt"
mapM_ print $ product <$> fromJust <$> flip (find_n_summing 2020) nums <$> [2, 3]