gqG
This commit is contained in:
parent
4bbed10f38
commit
1bb30457aa
|
@ -1,6 +1,6 @@
|
|||
import Data.Char
|
||||
import Data.Function (on)
|
||||
import Data.List
|
||||
import Data.Char
|
||||
|
||||
data Hand =
|
||||
C Int Int Int Int Int
|
||||
|
@ -35,13 +35,13 @@ main = do
|
|||
print $ day07 (parse False input)
|
||||
print $ day07 (parse True input)
|
||||
|
||||
|
||||
day07 :: [(Hand, Int)] -> Int
|
||||
day07 = sum . zipWith (*) [1 ..] . map snd . sort
|
||||
|
||||
parse :: Bool -> String -> [(Hand, Int)]
|
||||
parse p2 = map (f . words) . lines
|
||||
where f [x,y] = (parseHand x, read y)
|
||||
where
|
||||
f [x, y] = (parseHand x, read y)
|
||||
f x = error ("parse: Malformed input: " ++ show x)
|
||||
parseHand = g . map (digitToCard p2)
|
||||
g [x1, x2, x3, x4, x5] = C x1 x2 x3 x4 x5
|
||||
|
|
Loading…
Reference in New Issue
Block a user