本文整理汇总了Python中sudoku.Sudoku.print_sudoku方法的典型用法代码示例。如果您正苦于以下问题:Python Sudoku.print_sudoku方法的具体用法?Python Sudoku.print_sudoku怎么用?Python Sudoku.print_sudoku使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sudoku.Sudoku
的用法示例。
在下文中一共展示了Sudoku.print_sudoku方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from sudoku import Sudoku [as 别名]
# 或者: from sudoku.Sudoku import print_sudoku [as 别名]
#!/usr/bin/env python
#coding:utf-8
from sudoku import Sudoku
# Reading of sudoku list from file
try:
f = open("sudokus.txt", "r")
sudokuList = f.read()
except:
print "Error in reading the sudoku file."
exit()
# 1.5 count number of sudokus solved by AC-3
num_ac3_solved = 0
for line in sudokuList.split("\n"):
s = Sudoku(line)
if s.solve_ac3():
num_ac3_solved += 1
s.print_sudoku()
else:
print "Failed to solve using AC-3"
print "Solved %d sudokus using AC-3 inference" % num_ac3_solved
# 1.6 solve all sudokus by backtracking
for line in sudokuList.split("\n"):
s = Sudoku(line)
if s.solve_backtrack():
s.print_sudoku()
else:
print "Failed to solve using backtrack"
示例2: Sudoku
# 需要导入模块: from sudoku import Sudoku [as 别名]
# 或者: from sudoku.Sudoku import print_sudoku [as 别名]
from sudoku import Sudoku
from timer import Timer, calculate_time
import sys
from solve import solve_sudoku
if __name__ == '__main__':
arg = sys.argv[1]
sudoku = Sudoku()
if arg is None:
sudoku.load_data_from_file()
if arg is not None:
if arg.find('/') >= 0:
sudoku.load_data_from_file(arg)
else:
sudoku.load_data_from_argv(arg)
sudoku.print_sudoku(stdout=False)
sudoku.pre_calculate()
with Timer(True) as t:
# cursor = 0
solve_sudoku(sudoku)
sudoku.print_sudoku(stdout=False)