def readSudoku():
c = int(stdin.readline())
sudoku = []
for i in range(c**2):
sudoku.append([int(j) for j in stdin.readline().strip().split()])
return sudoku,c
def testLine(l):
h = []
for i in l:
if i > len(l):
return False
if h.count(i) == 0:
h.append(i)
else:
return False
return True
def solveSudoku(sudoku,n):
for line in sudoku:
if testLine(line) == False:
return "No"
for i in range(len(sudoku)):
line = [j[i] for j in sudoku]
if testLine(line) == False:
return "No"
for i in range(len(sudoku)):
line = []
for j in range(i / n, i / n + n):
#print sudoku[j][i:i / n + n],i,i / n + n
line.extend(sudoku[j][i * n:i / n + n])
if testLine(line) == False:
return "No"
return "Yes"
sudoku
最新推荐文章于 2018-12-24 15:17:59 发布