diff --git a/src/Sudoku.hs b/src/Sudoku.hs index 70c91f4..0ab20f9 100644 --- a/src/Sudoku.hs +++ b/src/Sudoku.hs @@ -13,9 +13,10 @@ possibleVals (Fixed x) = [x] possibleVals (Possible xs) = xs readGrid :: String -> Maybe Grid -readGrid s = if length s /= 81 - then Nothing - else sequence . map (sequence . map readCell) . Data.List.Split.chunksOf 9 $ s +readGrid s + | length s == 81 = + sequence . map (sequence . map readCell) . Data.List.Split.chunksOf 9 $ s + | otherwise = Nothing where readCell '.' = Just $ Possible [1..9] readCell c @@ -33,7 +34,9 @@ showGridWithPossibilities = unlines . map (unwords . map showCell) where showCell (Fixed x) = show x ++ " " showCell (Possible xs) = - (Data.List.foldl' (\acc x -> acc ++ if x `elem` xs then show x else " ") "[" [1..9]) ++ "]" + (++ "]") + . Data.List.foldl' (\acc x -> acc ++ if x `elem` xs then show x else " ") "[" + $ [1..9] main = undefined \ No newline at end of file