MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / solve

Function solve

Sudoku_solver/main.py:125–148  ·  view source on GitHub ↗
(bo)

Source from the content-addressed store, hash-verified

123
124
125def solve(bo):
126 # searching for next empty solt
127 slot = next_empty(bo)
128 if not slot:
129 # return True if there is no empty slot
130 return True
131 else:
132 row, col = slot
133 # looping number 1 to 9
134 for i in range(1, 10):
135 # check if the number is possible in this location
136 if possible(bo, (row, col), i):
137 # placing the number on the board
138 bo[row][col] = i
139
140 # starting recursion
141 if solve(bo):
142 # returns True when the previous returned True
143 # This will only activate if the board is full
144 return True
145
146 # resetting the changed value to 0
147 bo[row][col] = 0
148 return False
149
150
151# Fill your numbers in the board below or create a new array to solve the board you give.

Callers 1

main.pyFile · 0.85

Calls 2

next_emptyFunction · 0.85
possibleFunction · 0.85

Tested by

no test coverage detected