本文整理汇总了Python中sudoku.Sudoku.recursive_solve方法的典型用法代码示例。如果您正苦于以下问题:Python Sudoku.recursive_solve方法的具体用法?Python Sudoku.recursive_solve怎么用?Python Sudoku.recursive_solve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sudoku.Sudoku
的用法示例。
在下文中一共展示了Sudoku.recursive_solve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_recursive_solve
# 需要导入模块: from sudoku import Sudoku [as 别名]
# 或者: from sudoku.Sudoku import recursive_solve [as 别名]
def test_recursive_solve():
rec_sudoku = " , , , , 5, 3, , , ;\n" + \
"1, , , 6, , , , , 8;\n" + \
" , 5, , , , 1, , 4, ;\n" + \
"4, , , , 9, , 5, 3, ;\n" + \
" , , 9, 7, , 6, 8, , ;\n" + \
" , 2, 7, , 3, , , , 6;\n" + \
" , 4, , 1, , , , 8, ;\n" + \
"2, , , , , 7, , , 1;\n" + \
" , , , 3, 2, , , , ;\n"
solution = "6, 8, 4, 2, 5, 3, 1, 7, 9;\n" + \
"1, 9, 3, 6, 7, 4, 2, 5, 8;\n" + \
"7, 5, 2, 9, 8, 1, 6, 4, 3;\n" + \
"4, 1, 6, 8, 9, 2, 5, 3, 7;\n" + \
"5, 3, 9, 7, 1, 6, 8, 2, 4;\n" + \
"8, 2, 7, 4, 3, 5, 9, 1, 6;\n" + \
"3, 4, 5, 1, 6, 9, 7, 8, 2;\n" + \
"2, 6, 8, 5, 4, 7, 3, 9, 1;\n" + \
"9, 7, 1, 3, 2, 8, 4, 6, 5;\n"
sudoku = Sudoku()
sudoku.read_string(rec_sudoku)
sudoku.recursive_solve()
assert_equal(str(sudoku), solution)
示例2: test_incorrect_sudoku
# 需要导入模块: from sudoku import Sudoku [as 别名]
# 或者: from sudoku.Sudoku import recursive_solve [as 别名]
def test_incorrect_sudoku():
incorrect = "1, 2, 3, , , , , , ;\n" + \
"4, 5, 6, , , , , , ;\n" + \
"7, 8, , 9, , , , , ;\n" + \
" , , , , , , , , ;\n" + \
" , , , , , , , , ;\n" + \
" , , , , , , , , ;\n" + \
" , , , , , , , , ;\n" + \
" , , , , , , , , ;\n" + \
" , , , , , , , , ;\n"
sudoku = Sudoku()
sudoku.read_string(incorrect)
sudoku.recursive_solve()