trees reduce(matrix if not solutionviable(matrix)return none if solutionok(matrix)return matrix print("searching " for in range( )for in range( )if len(matrix[ ][ ] for in matrix[ ][ ]mcopy copy deepcopy(matrixmcopy[ ][jset([ ] result solve(mcopy if result !nonereturn result return none in the solve function of sect reduce is called to try to solve the puzzle with the rules of the last after calling reduce we check to see if the puzzle is still solvable ( no empty setsif notthe solve function returns none the search proceeds by examining each location within the matrix and each possible value that the location could hold the for loop tries all possible values for cell with more than one possibility if the call to reduce solves the puzzlethe solutionok function will return true and the solve function will return the matrix otherwisethe depth first search proceeds by looking for cell in the matrix with more than one choice the function makes copy of the matrix called mcopy and makes guess as to the value in that location in mcopy it then recursively calls solve on mcopy the solve function returns none if no solution is found and the solved puzzle if solution is found sowhen solve is called recursivelyif none is returnedthe function continues to search by trying another possible value initially calling solve can be accomplished as shown in sect assuming that matrix is matrix of sets representing sudoku puzzle calling sudoku' solve function print("begin solving" matrix solve(matrix if matrix =noneprint("no solution found!!!"return this copy belongs to 'acha