这个专案是一个Python 程式库以便让使用者学习逻辑与Python 程式设计。它包含了两个套件,一个是Sudoku,另一个是Matrix。 Sudoku 是一个以物件导向程式设计的模组,而Matrix 则是一个传统程式设计的模组。
这个专案与文件只要是提供给Sudoku 套件来使用。 Matrix 只是提供给传统程式设计者做一参考。
你可以使用 pip 来安装这个专案:
pip install SudokuStudyLib
你也可以到下列网址来复制整个专案:
https://github.com/RobertOfTaiwan/SudokuStudyLib
当你安装完毕后,你安装的目录应包含了两个套件,sudoku 及matrix。下面就是整个目录的结构表:
物件导向:sudoku,在 test.py:
from sudoku import *
# to solve a sudoku defined in data directory
solve("m18.data")
pass
# to solve a sudoku and just using the methods which level <= 15 and if can't solve, don't use guess method
solve("m3.data", level_limit=15, use_try=False)
pass
# to solve a sudoku with emulator methods and print the steps
solve("m12.data", use_emu=True, print_step=True)
pass
# to solve the world's best difficult sudoku
# by default method
solve("m10.data")
# by computer's try error
try_error(None, file="m10.data")
# by all methods but not using human guessing, it can't solve the sudoku
solve("m10.data", use_emu=True, use_try=False)
# by basic human methods and guess
solve("m10.data", level_limit=10, use_try=True)
solve("m10.data", level_limit=3, use_try=True)
传统方法 :matrix,在 test.py:
from matrix import *
# solve it directly
m, n, p = main("m6.data")
# solve it by limit methods, it can't solve the sudoku
m, n, p = main("m3.data", methods=8)
# set the limit methods to the 10, and it can solve the sudoku
m, n, p = main("m3.data", methods=10)
# using the try error's method to solve the best difficult sudoku in the world
m, n, p = TryError("m10.data")