当前位置: 首页>>代码示例>>Python>>正文


Python Sudoku.print_sudoku方法代码示例

本文整理汇总了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"
开发者ID:mcassiano,项目名称:ai-hw4-csp,代码行数:33,代码来源:hw4_mcc2224.py

示例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)


开发者ID:wsasocket,项目名称:sudoku,代码行数:25,代码来源:main.py


注:本文中的sudoku.Sudoku.print_sudoku方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。