本文整理汇总了Python中sudoku.Sudoku.countMissing方法的典型用法代码示例。如果您正苦于以下问题:Python Sudoku.countMissing方法的具体用法?Python Sudoku.countMissing怎么用?Python Sudoku.countMissing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sudoku.Sudoku
的用法示例。
在下文中一共展示了Sudoku.countMissing方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from sudoku import Sudoku [as 别名]
# 或者: from sudoku.Sudoku import countMissing [as 别名]
def main(debug):
from sudoku import Sudoku
solved = [
[2,4,8,3,9,5,7,1,6],
[5,7,1,6,2,8,3,4,9],
[9,3,6,7,4,1,5,8,2],
[6,8,2,5,3,9,1,7,4],
[3,5,9,1,7,4,6,2,8],
[7,1,4,8,6,2,9,5,3],
[8,6,3,4,1,7,9,2,5],
[1,9,5,2,8,6,4,3,7],
[4,2,7,9,5,3,8,6,1]]
unsolved = [
[0,0,0,0,0,0,0,0,0],
[1,1,1,1,1,1,1,1,1],
[2,2,2,2,2,2,2,2,2],
[3,3,3,3,3,3,3,3,3],
[4,4,4,4,4,4,4,4,4],
[5,5,5,5,5,5,5,5,5],
[6,6,6,6,6,6,6,6,6],
[7,7,7,7,7,7,7,7,7],
[8,8,8,8,8,8,8,8,8]]
sudoku = Sudoku(solved)
unsolvedSudoku = Sudoku(unsolved)
if debug: print 'test getRow'
for i in range(9):
try:
assert(solved[i] == sudoku.getRow(i))
except:
if debug: print 'ERROR----->r:', solved[i], '\tmethod:', sudoku.getRow(i); exit()
for i in range(9):
try:
assert(unsolved[i] == unsolvedSudoku.getRow(i))
except:
if debug: print 'ERROR----->r:', unsolved[i], '\tmethod:', unsolvedSudoku.getRow(i); exit()
if debug: print 'passed getRow\n'
if debug: print 'test getColumn'
for i in range(9):
columns = []
for x in range(9):
columns.append(solved[x][i])
try:
assert(columns == sudoku.getColumn(i))
except:
if debug: print 'ERROR----->c:', columns, '\tmethod:', sudoku.getColumn(i); exit()
for i in range(9):
columns = []
for x in range(9):
columns.append(unsolved[x][i])
try:
assert(columns == unsolvedSudoku.getColumn(i))
except:
if debug: print 'ERROR----->c:', columns, '\tmethod:', unsolvedSudoku.getColumn(i); exit()
if debug: print 'passed getColumn\n'
#-----------------------------------------------------------------------------------------
if debug: print 'test countMissing'
try:
assert(0 == sudoku.countMissing())
except:
if debug: print 'ERROR----->m:', 0, '\tmethod:', sudoku.countMissing(); exit()
try:
assert(9 == unsolvedSudoku.countMissing())
except:
if debug: print 'ERROR----->m:', 9, '\tmethod:', unsolvedSudoku.countMissing(); exit()
if debug: print 'passed countMissing\n'
#-----------------------------------------------------------------------------------------
if debug: print 'test countMissing row'
try:
assert(0 == sudoku.countMissing(row = 0))
except:
if debug: print 'ERROR----->m:', 0, '\tmethod:', sudoku.countMissing(row = 0); exit()
try:
assert(9 == unsolvedSudoku.countMissing(row = 0))
except:
if debug: print 'ERROR----->m:', 9, '\tmethod:', unsolvedSudoku.countMissing(row = 0); exit()
if debug: print 'passed countMissing row\n'
#-----------------------------------------------------------------------------------------
if debug: print 'test countMissing column'
try:
assert(0 == sudoku.countMissing(column = 0))
except:
if debug: print 'ERROR----->m:', 0, '\tmethod:', sudoku.countMissing(column = 0); exit()
try:
assert(1 == unsolvedSudoku.countMissing(column = 0))
#.........这里部分代码省略.........