Skip to content

Instantly share code, notes, and snippets.

@abhin4v
Created January 22, 2019 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhin4v/af131df51e3416b0be062a8cba60dcca to your computer and use it in GitHub Desktop.
Save abhin4v/af131df51e3416b0be062a8cba60dcca to your computer and use it in GitHub Desktop.
readGrid :: String -> Maybe Grid
readGrid s
| length s == 81 = traverse (traverse readCell) . Data.List.Split.chunksOf 9 $ s
| otherwise = Nothing
where
readCell '.' = Just $ Possible [1..9]
readCell c
| Data.Char.isDigit c && c > '0' = Just . Fixed . Data.Char.digitToInt $ c
| otherwise = Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment