day1: add haskell solution
This commit is contained in:
parent
693ed4558e
commit
e04c222407
1 changed files with 12 additions and 0 deletions
12
day1/day1.hs
Normal file
12
day1/day1.hs
Normal 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]
|
Loading…
Reference in a new issue