Uh oh!
There was an error while loading. Please reload this page.
Added validate sudoku board function - #9881
Conversation
cclauss
commented
Oct 6, 2023
I think we already have this well covered. https://github.com/TheAlgorithms/Python/blob/master/backtracking/sudoku.py https://github.com/TheAlgorithms/Python/pulls?q=is%3Apr+sudoku |
Uh oh!
There was an error while loading. Please reload this page.
cclauss
commented
Oct 6, 2023
|
dbring
commented
Oct 6, 2023
Yeah, I saw this but I think validating a sudoku board is a materially different task than solving it. Happy to close this if you feel otherwise. |
cclauss
commented
Oct 6, 2023
You have two different files in this pull request. |
cclauss
commented
Oct 6, 2023
Old but nice ideas!! http://norvig.com/sudoku.html |
dbring
commented
Oct 8, 2023
@cclauss was there anything else you wanted me to amend? |
| NUM_ROWS = 9 | ||
| NUM_COLS = 9 | ||
| EMPTY_CELL = "." | ||
| IS_VALID = True |
There was a problem hiding this comment.
Let's use NUM_SQUARES instead of NUM_ROWS and NUM_ROWS.
Lets True and False in a boolean function.
| NUM_ROWS=9 | |
| NUM_COLS=9 | |
| EMPTY_CELL="." | |
| IS_VALID=True | |
| NUM_SQUARES=9 | |
| EMPTY_CELL="." |
| if len(sudoku_board) != NUM_ROWS: | ||
| raise Exception("Number of rows must be 9.") | ||
| for row in sudoku_board: | ||
| if len(row) != NUM_COLS: | ||
| raise Exception("Number of columns must be 9.") |
There was a problem hiding this comment.
| iflen(sudoku_board) !=NUM_ROWS: | |
| raiseException("Number of rows must be 9.") | |
| forrowinsudoku_board: | |
| iflen(row) !=NUM_COLS: | |
| raiseException("Number of columns must be 9.") | |
| iflen(sudoku_board) !=NUM_SQUARESorany( | |
| len(row) !=NUM_SQUARESforrowinsudoku_board | |
| ): | |
| raiseValueError(f"Sudoku boards must be {NUM_SQUARES}x{NUM_SQUARES} squares.") |
Uh oh!
There was an error while loading. Please reload this page.
Describe your change:
Checklist: