本文整理汇总了Python中sudoku.Sudoku.create方法的典型用法代码示例。如果您正苦于以下问题:Python Sudoku.create方法的具体用法?Python Sudoku.create怎么用?Python Sudoku.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sudoku.Sudoku
的用法示例。
在下文中一共展示了Sudoku.create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_sudoku
# 需要导入模块: from sudoku import Sudoku [as 别名]
# 或者: from sudoku.Sudoku import create [as 别名]
def create_sudoku(filename):
"""Create a sudoku with handicap and save it to filename.
The handicap are the extra numbers given.
Arguments:
filename -- the file name
"""
while True:
print _(u"Creating sudoku..."),
sys.stdout.flush()
sudoku = Sudoku(Board((options.getint("sudoku", "region_width"),
options.getint("sudoku", "region_height"))),
difficulty=options.get("sudoku", "difficulty"))
sudoku.create(options.getint("sudoku", "handicap"))
if options.getboolean("sudoku", "force") and \
(difficulty(sudoku.to_board()) != options.get("sudoku",
"difficulty")):
print _(u"sudoku with wrong difficulty!")
else:
sudoku.to_board().save(filename)
print _(u"success!")
break
draw_board(sudoku.to_board())
return True