Question: In PYTHON! Write a pure function named checkSudoku that will check a proposed Sudoku puzzle solution and return True if it's correct, False otherwise. The
In PYTHON!
Write a pure function named checkSudoku that will check a proposed Sudoku puzzle solution and return True if it's correct, False otherwise. The puzzle grid is represented using a two-dimensional list with 9 rows and 9 columns, and is passed as a single argument to the checkSudoku function.
There are two basic approaches to checking the solution:
1). Verify that every row, column and sub-square contains all the digits 1-9
or
2). Check every cell in the grid and verify that is unique among all the elements in its row, column and subsquare.
[Hint: you can obtain the index [a][b] of the upper-left corner a 3x3 sub-square for any grid index [i][j] using the following: a = i//3*3, b = j//3*3
Write a separate unitTest procedure (non-pure function) that will call checkSudoku and display either "Solution" or "Not a solution" for each of the following (at a minimum):
[ [5,3,4,6,7,8,9,1,2], \
[6,7,2,1,9,5,3,4,8], \
[1,9,8,3,4,2,5,6,7], \
[8,5,9,7,6,1,4,2,3], \
[4,2,6,8,5,3,7,9,1], \
[7,1,3,9,2,4,8,5,6], \
[9,6,1,5,3,7,2,8,4], \
[2,8,7,4,1,9,6,3,5], \
[3,4,5,2,8,6,1,7,9] ]
and
[ [5,3,4,6,7,8,9,1,2], \
[6,7,2,1,9,5,3,4,8], \
[1,9,8,3,4,2,4,6,7], \
[8,5,9,7,6,1,5,2,3], \
[4,2,6,8,5,3,7,9,1], \
[7,1,3,9,2,4,8,5,6], \
[9,6,1,5,3,7,2,8,4], \
[2,8,7,4,1,9,6,3,5], \
[3,4,5,2,8,6,1,7,9] ]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
