-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy path037-4kyu-Sudoku Solution Validator.py
More file actions
36 lines (33 loc) · 1014 Bytes
/
037-4kyu-Sudoku Solution Validator.py
File metadata and controls
36 lines (33 loc) · 1014 Bytes
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
29
30
31
32
33
34
35
36
def validSolution(board):
temp = []
for row in board:
print row
for i in range(1,10):
if i not in row:
# print row, "row failed"
return False
print "~~~~~~~~~Row Passed~~~~~~~~~~"
for column in range(0,9):
temp = []
for row in board:
temp.append(row[column])
# print temp
for i in range(1,10):
if i not in temp:
# print temp, "column failed"
return False
print "~~~~~~~~~~~Column passed~~~~~~~~~~~~~~~~~~~~~~"
j = 0
while (j <=2):
temp = []
for row in range(3*j,3*j+3):
k = 0
for column in range(3*j,3*j+3):
temp.append(board[row][column])
# print temp, row, column
# print temp
for i in range(1,10):
if temp.count(i) != 1:
return False
j += 1
return True