day1: add haskell solution

This commit is contained in:
Xiretza 2020-12-02 10:12:00 +01:00
parent 693ed4558e
commit e04c222407
Signed by: xiretza
GPG key ID: 17B78226F7139993

12
day1/day1.hs Normal file
View file

@ -0,0 +1,12 @@
{-# 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]