From 1b9ea3c36d2f32bedc0416898764f6039320274e Mon Sep 17 00:00:00 2001 From: tzlil Date: Sat, 2 Dec 2023 15:22:56 +0200 Subject: pass filename to parse --- 2/2.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '2/2.hs') diff --git a/2/2.hs b/2/2.hs index ed96a26..4437594 100644 --- a/2/2.hs +++ b/2/2.hs @@ -7,7 +7,7 @@ import Data.Maybe import qualified Data.Map as M import Control.Monad -data Color = Red | Green | Blue deriving (Eq,Ord) +data Color = Red | Green | Blue deriving (Show,Eq,Ord) type Handful = (Color, Int) type Set = M.Map Color Int type Game = (Int, [Set]) @@ -30,4 +30,4 @@ games = sepBy game newline solution :: Game -> Int solution = product . M.elems . M.unionsWith max . snd -main = head <$> getArgs >>= readFile >>= print . sum . map solution . either (error.show) id . parse games "" \ No newline at end of file +main = head <$> getArgs >>= ((=<<) . ((print . sum . map solution . either (error . show) id) .) . parse games) <*> readFile \ No newline at end of file -- cgit 1.4.1