PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# A Backtracking program in Pyhton to solve Sudoku problem
# disp() dipslays the sudoku matrix on the screen
def disp(sudoku):
print ('\n\n')
for row in range(len(sudoku)):
print('\t',end='')
for col in range(len(sudoku[row])):
print (sudoku[row][col],end = ' ')
print('\n')
# Function to Find the entry in the Grid that is still not used
# Searches the grid to find an entry that is still unassigned. If
# found, the reference parameters row, col will be set the location
# that is unassigned, and true is returned. If no unassigned entries
# remain, false is returned.
# 'l' is a list variable that has been passed from the solve_sudoku function
# to keep track of incrementation of Rows and Columns
def find_empty_location(arr,l):
for row in range(9):
for col in range(9):
if(arr[row][col]==0):
l[0]=row
l[1]=col
return True
return False
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run