summary refs log tree commit diff
path: root/2/2.hs
diff options
context:
space:
mode:
authortzlil <tzlils@protonmail.com>2023-12-02 15:22:56 +0200
committertzlil <tzlils@protonmail.com>2023-12-02 15:22:56 +0200
commit1b9ea3c36d2f32bedc0416898764f6039320274e (patch)
treeea0d0ea980fc117bc89e670bce465d626daef14b /2/2.hs
parentd7e41f1e93eac045329b6ea91ae150d517e443a3 (diff)
pass filename to parse
Diffstat (limited to '2/2.hs')
-rw-r--r--2/2.hs4
1 files changed, 2 insertions, 2 deletions
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