/sudoku_plus

Sudoku Plus is a complete Python toolkit for Sudoku enthusiasts, hobbyists, and developers. Whether you want to generate challenging puzzles, solve them programmatically, or validate solutions, this project provides all the tools you need.

Primary LanguagePythonMIT LicenseMIT

Sudoku Plus ๐Ÿงฉ

Sudoku Plus is a complete Python toolkit for Sudoku enthusiasts, hobbyists, and developers. Whether you want to generate challenging puzzles, solve them programmatically, or validate solutions, this project provides all the tools you need.

With a clean CLI interface, modular Python code, and a full test suite, Sudoku Plus is perfect for learning algorithms, experimenting with puzzle generation techniques, or integrating Sudoku features into your own projects.

A complete Sudoku toolkit in Python featuring:

  • Sudoku board generator
  • Sudoku solver (backtracking + optional advanced heuristics)
  • Validator (check if a Sudoku is valid)
  • CLI interface for generating and solving puzzles
  • Test suite for all modules

๐Ÿ“‚ Project Structure

sudoku_plus/
โ”‚โ”€โ”€ src/
โ”‚   โ””โ”€โ”€ sudoku_plus/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ board.py
โ”‚       โ”œโ”€โ”€ generator.py
โ”‚       โ”œโ”€โ”€ solver.py
โ”‚       โ”œโ”€โ”€ validator.py
โ”‚       โ””โ”€โ”€ cli.py
โ”‚
โ”‚โ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_board.py
โ”‚   โ”œโ”€โ”€ test_generator.py
โ”‚   โ”œโ”€โ”€ test_solver.py
โ”‚   โ”œโ”€โ”€ test_validator.py
โ”‚
โ”‚โ”€โ”€ main.py
โ”‚โ”€โ”€ requirements.txt
โ”‚โ”€โ”€ README.md

โšก Installation

Clone this repository:

git clone https://github.com/BaseMax/sudoku_plus.git
cd sudoku_plus

(Optional) Create a virtual environment:

python3 -m venv venv

On Linux:

source venv/bin/activate

On Windows:

venv\Scripts\activate

Install requirements:

pip install -r requirements.txt

Install your project in editable mode

From project root:

pip install -e .

-e = editable โ†’ you can edit source code without reinstalling.

After this, sudoku_plus is recognized as a proper Python package.

Run your CLI anywhere

Now you can do:

python -m sudoku_plus.cli gen --size 9 --difficulty medium

Or, because we added [project.scripts], you can also run directly:

sudoku gen --size 9 --difficulty medium

๐Ÿ”น Generate a Sudoku Puzzle

python -m sudoku_plus.cli gen --size 9 --difficulty medium
  • --size โ†’ board size (default: 9)
  • --difficulty โ†’ easy | medium | hard

Example:

python -m sudoku_plus.cli gen --size 9 --difficulty hard

๐Ÿ”น Solve a Sudoku Puzzle

Provide a puzzle as a string (0 = empty):

python -m sudoku_plus.cli solve "530070000600195000098000060800060003400803001700020006060000280000419005000080079"

Or read from file:

python -m sudoku_plus.cli solve --file puzzle.txt

๐Ÿ”น Validate a Sudoku Board

python -m sudoku_plus.cli validate <puzzle_string> <solution_string>

For example:

python -m sudoku_plus.cli validate "530070000600195000098000060800060003400803001700020006060000280000419005000080079" "534678912672195348198342567859761423426853791713924856961537284287419635345286179"

๐Ÿงช Running Tests

Tests are written with pytest. To run all tests:

pytest tests/

Run a specific test file:

pytest tests/test_solver.py

โœจ Features Roadmap

  • Basic solver (backtracking)
  • Random puzzle generator
  • CLI interface
  • Test suite
  • GUI visualizer (Tkinter/PyGame)
  • Advanced solving strategies (human-like techniques)
  • Export puzzles to .txt / .csv

๐Ÿ“œ License

MIT License ยฉ 2025 BaseMax