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

Function possible

Sudoku_solver/main.py:89–112  ·  view source on GitHub ↗
(bo, pos, num)

Source from the content-addressed store, hash-verified

87
88
89def possible(bo, pos, num):
90 # checking row
91 for i in range(len(bo[0])):
92 if bo[pos[0]][i] == num and pos[1] != i:
93 # not possible
94 return False
95
96 # checking column
97 for i in range(len(bo)):
98 if bo[i][pos[1]] == num and pos[0] != i:
99 # not possible
100 return False
101
102 # checking square
103 box_x = pos[1] // 3
104 box_y = pos[0] // 3
105
106 for i in range(box_y * 3, box_y * 3 + 3): # row
107 for j in range(box_x * 3, box_x * 3 + 3): # col
108 if bo[i][j] == num and (i, j) != pos:
109 # not possible number
110 return False
111 # possible number
112 return True
113
114
115def next_empty(bo):

Callers 1

solveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected