Valid Sudoku
Medium
LC #36
hash setmatrixtuple keysNot attempted yet
You get a 9x9 Sudoku board as a list of 9 rows; each cell
is a one-character string: a digit "1"-"9" or
"." for empty.
Return True if the filled cells break no rule:
- no digit repeats within a row
- no digit repeats within a column
- no digit repeats within any of the nine 3x3 boxes
The board doesn't have to be solvable; only check what's there.
Example 1
Input: board =
5 3 . | . 7 . | . . .
6 . . | 1 9 5 | . . .
. 9 8 | . . . | . 6 .
------+-------+------
8 . . | . 6 . | . . 3
4 . . | 8 . 3 | . . 1
7 . . | . 2 . | . . 6
------+-------+------
. 6 . | . . . | 2 8 .
. . . | 4 1 9 | . . 5
. . . | . 8 . | . 7 9
Output: True
Example 2
Input: the same board, but the
top-left cell is "8" instead of "5"
Output: False
The top-left box now has two 8s.
Example 3
Input: a board of all "."
Output: True
Constraints
- len(board) == 9, len(board[i]) == 9
- board[i][j] is "1"-"9" or "."