Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions matrix/validate_sudoku_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,66 @@ def is_valid_sudoku_board(sudoku_board: list[list[str]]) -> bool:
... ,[".",".",".",".","8",".",".","7","9"]
... ])
False
>>> is_valid_sudoku_board([
... ["1","2","3","4","5","6","7","8","9"]
... ,["4","5","6","7","8","9","1","2","3"]
... ,["7","8","9","1","2","3","4","5","6"]
... ,[".",".",".",".",".",".",".",".","."]
... ,[".",".",".",".",".",".",".",".","."]
... ,[".",".",".",".",".",".",".",".","."]
... ,[".",".",".",".",".",".",".",".","."]
... ,[".",".",".",".",".",".",".",".","."]
... ,[".",".",".",".",".",".",".",".","."]
... ])
True
>>> is_valid_sudoku_board([
... ["1","2","3",".",".",".",".",".","."]
... ,["4","5","6",".",".",".",".",".","."]
... ,["7","8","9",".",".",".",".",".","."]
... ,[".",".",".","4","5","6",".",".","."]
... ,[".",".",".","7","8","9",".",".","."]
... ,[".",".",".","1","2","3",".",".","."]
... ,[".",".",".",".",".",".","7","8","9"]
... ,[".",".",".",".",".",".","1","2","3"]
... ,[".",".",".",".",".",".","4","5","6"]
... ])
True
>>> is_valid_sudoku_board([
... ["1","2","3",".",".",".","5","6","4"]
... ,["4","5","6",".",".",".","8","9","7"]
... ,["7","8","9",".",".",".","2","3","1"]
... ,[".",".",".","4","5","6",".",".","."]
... ,[".",".",".","7","8","9",".",".","."]
... ,[".",".",".","1","2","3",".",".","."]
... ,["3","1","2",".",".",".","7","8","9"]
... ,["6","4","5",".",".",".","1","2","3"]
... ,["9","7","8",".",".",".","4","5","6"]
... ])
True
>>> is_valid_sudoku_board([
... ["1","2","3","4","5","6","7","8","9"]
... ,["2",".",".",".",".",".",".",".","8"]
... ,["3",".",".",".",".",".",".",".","7"]
... ,["4",".",".",".",".",".",".",".","6"]
... ,["5",".",".",".",".",".",".",".","5"]
... ,["6",".",".",".",".",".",".",".","4"]
... ,["7",".",".",".",".",".",".",".","3"]
... ,["8",".",".",".",".",".",".",".","2"]
... ,["9","8","7","6","5","4","3","2","1"]
... ])
False
>>> is_valid_sudoku_board([
... ["1","2","3","8","9","7","5","6","4"]
... ,["4","5","6","2","3","1","8","9","7"]
... ,["7","8","9","5","6","4","2","3","1"]
... ,["2","3","1","4","5","6","9","7","8"]
... ,["5","6","4","7","8","9","3","1","2"]
... ,["8","9","7","1","2","3","6","4","5"]
... ,["3","1","2","6","4","5","7","8","9"]
... ,["6","4","5","9","7","8","1","2","3"]
... ,["9","7","8","3","1","2","4","5","6"]
... ])
True
>>> is_valid_sudoku_board([["1", "2", "3", "4", "5", "6", "7", "8", "9"]])
Traceback (most recent call last):
...
Expand Down