Added tests for validate_sudoku_board.py (#11108)

This commit is contained in:
Akshar Goyal 2023-10-30 20:00:48 -04:00 committed by GitHub
parent 79a327fc07
commit b072ba657f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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):
...