目次

前のトピックへ

SudokuStudyLib

次のトピックへ

数独 (数独) の基礎

このページ

インストールと使用

このプロジェクトは、ユーザーはPythonプログラミングロジックとデザインを学ぶことを可能にするPythonのライブラリです。それは、一方が他方が行列数独、ある2つのパッケージが含まれています。数独は、モジュラーオブジェクト指向プログラミングであり、マトリックスは、従来のプログラミングモジュールである。

このプロジェクトは限りファイルを使用するために数独キットに提供される。伝統的なプログラムへの参照を行うため、設計者だけが利用できる行列。

インストール

あなたは、PIP、このプロジェクトをインストールを使用することができます:

pip install SudokuStudyLib

また、プロジェクト全体をコピーするには、以下のWebサイトにアクセスすることができます:

https://github.com/RobertOfTaiwan/SudokuStudyLib

あなたがインストールしているときは、ディレクトリは2つのパッケージ数独と行列が含まれているインストールする必要があります。ここでは、テーブル全体のディレクトリ構造は次のとおりです。

_images/p1.png

使用

  1. オブジェクト指向:数独、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)
    
  2. 伝統的な方法:マトリックス、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")