Improve code in Haskell solution for Problem 54

This commit is contained in:
daniele 2024-11-17 12:16:15 +01:00
parent 74d32924a7
commit 7a67ad0659
Signed by: fuxino
GPG Key ID: 981A2B2A3BBF5514

View File

@ -211,9 +211,8 @@ playGame g
in if xs > ys then 1 else -1
main = do
withFile "p054_poker.txt" ReadMode (\handle -> do
contents <- hGetContents handle
let games = map readGame (lines contents)
result = sum $ filter (==1) $ map playGame games
putStrLn $ "Project Euler, Problem 54\n"
++ "Answer: " ++ show result)
contents <- readFile "p054_poker.txt"
let games = map readGame (lines contents)
result = sum $ filter (==1) $ map playGame games
putStrLn $ "Project Euler, Problem 54\n"
++ "Answer: " ++ show result