You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
module Main where
|
|
|
|
main :: IO ()
|
|
main = interact solution
|
|
|
|
type Board = [[Int]]
|
|
type BoardMask = [[Bool]]
|
|
|
|
scnd :: (b -> c) -> (a, b) -> (a, c)
|
|
scnd f (a, b) = (a, f b)
|
|
|
|
frst :: (a -> c) -> (a, b) -> (c, b)
|
|
frst f (a, b) = (f a, b)
|
|
|
|
solution :: String -> String
|
|
solution =
|
|
show
|
|
-- ([Int], [Boards])
|
|
. scnd toBoards
|
|
. scnd (map (map (read :: String -> Int)))
|
|
. scnd (filter (not . null))
|
|
. scnd (map words)
|
|
. frst (map (read :: String -> Int))
|
|
. frst splitcomma
|
|
. (\x -> (head x, tail x))
|
|
. lines
|
|
where
|
|
splitcomma :: String -> [String] -- "stole" the implementation from `words`
|
|
splitcomma s = case dropWhile (==',') s of
|
|
"" -> []
|
|
s' -> w : splitcomma s''
|
|
where
|
|
(w, s'') = break (==',') s'
|
|
|
|
toBoards :: [[Int]] -> [Board]
|
|
toBoards [] = []
|
|
toBoards (a:b:c:d:e:r) = [a,b,c,d,e]:toBoards r
|
|
|
|
calculateScore :: Int -> -- ^ winning number
|
|
Board -> -- ^ winning board
|
|
BoardMask -> -- ^ drawn numbers
|
|
Int
|
|
calculateScore = undefined
|
|
|
|
checkWinning :: BoardMask -> Bool
|
|
checkWinning = undefined
|
|
|