/SudokuPlayer

This project comes in two parts. One is a puzzle solver. This solver will solve Sudoku puzzles using human methods (ie, it will not use back tracking to brute force the puzzle.) The other part is generating Sudoku puzzles.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Build Status codecov License: GPL v3 Code Style: Black

SudokuPlayer

This project comes in two parts. One is a puzzle solver. This solver will solve Sudoku puzzles using human methods (ie, it will not use back tracking to brute force the puzzle.) The other part is generating Sudoku puzzles.

Usage

This usage is broken into two seperate modules, a sudoku solver, and a sudoku generator.

PuzzleSolver

To run the algorithm on a basic puzzle, and to ensure that the code works for basic cases, simply use

python -m sudoku

To instead use this algorithm on your own puzzle, simply import the project, and create and run a puzzle solver.

import sudoku

p = sudoku.Puzzle(YOUR_PUZZLE)
ps = sudoku.PuzzleSover(p)

ps.solve_puzzle(verbose=True)

Using this setup, the solution and steps to your puzzle (if solvable) will be logged to the INFO level.

PuzzleGenerator

The puzzle generation feature has not yet been implemented.

Setup

This will guide you through setting up the environment to develop on this project.

Creating/Setting up a Virtual Environment

First create your virtual environment using

python -m virtualenv {environment name}

After a short while, a new directory under the name {environment name} will be created.

Next, you need to activate the vm. This is done differently on different operating systems. Deactvating however can be done the same on both systems.

Linux / MacOS

source {environment name}/Scripts/activate

Windows

{environment name}\Scripts\activate

Deactivation

deactivate

Installing Requirements

In order to install the development requirements, run

python -m pip install -r requirements-dev.txt

Setting up pre-commit

Once the requirements are installed, pre-commit can be used to ensure that builds don't fail due to poorly formatted code. This can be done with

pre-commit install

After running this command, commits will fail locally (and be automatically fixed) rather than failing at the build level (and need semi-manual fixes.)