Skip to content

yrangana/Sudoku-Solver-Core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Makefile CI

Sudoku Solver Core

This is the core module of a Sudoku solver project. It provides the logic for solving 9x9 Sudoku puzzles using an efficient backtracking algorithm. This module is designed to be part of a larger project that includes features like OCR and image processing for extracting Sudoku puzzles from images.


Features

  • Solve 9x9 Sudoku puzzles using a backtracking algorithm.
  • Validate puzzle input for correctness and consistency.
  • Display puzzles in a user-friendly format.
  • Designed for integration with other modules (e.g., OCR, image processing).
  • Timeout Functionality: Solve puzzles within a user-defined time limit.
  • Interactive Mode: Accept puzzles via user input or use default puzzles.

Setup

Prerequisites

  • Python 3.10 or higher
  • Virtual environment (recommended)

Installation

Install Runtime Dependencies

To use the Sudoku Solver Core package:

pip install git+https://github.com/yrangana/Sudoku-Solver-Core.git@main

Install Development Dependencies

To contribute or run tests, install with development dependencies:

pip install git+https://github.com/yrangana/Sudoku-Solver-Core.git@main[dev]

Local Development

For local development, clone the repository and install it in editable mode:

git clone https://github.com/yrangana/Sudoku-Solver-Core.git
cd Sudoku-Solver-Core
pip install -e .[dev]

Makefile Commands

This project includes a Makefile for common development tasks:

  • Install Dependencies: Install all required dependencies:

    make install
  • Run Tests: Execute the test suite:

    make test
  • Format Code: Format all Python files using black:

    make format
  • Lint Code: Lint all Python files using pylint:

    make lint
  • Clean Temporary Files: Clean up temporary files and cache:

    make clean
  • Run Project: If applicable, run the project locally:

    make run

Usage

  1. Import and use the Sudoku Solver Core in your Python project:

    from src.solver import solve_sudoku
    
    puzzle = [
        [5, 3, 0, 0, 7, 0, 0, 0, 0],
        [6, 0, 0, 1, 9, 5, 0, 0, 0],
        ...
    ]
    
    if solve_sudoku(puzzle):
        print("Solved Puzzle:", puzzle)
    else:
        print("No solution exists.")
  2. Interactive Mode: Run the main.py script to interact with the solver:

    python main.py

    Features:

    • Choose between a default puzzle or input your own.
    • Set a timeout for solving the puzzle.

    Example of input for custom puzzles:

    Enter your Sudoku puzzle row by row, using 0 for empty cells.
    Row 1: 5 3 0 0 7 0 0 0 0
    Row 2: 6 0 0 1 9 5 0 0 0
    ...
    Row 9: 0 0 0 0 8 0 0 7 9
    

Dependencies

Runtime

  • None (currently no runtime dependencies)

Development

  • black: Code formatting
  • click: CLI support
  • ipython: Interactive shell
  • pylint: Code linting
  • pytest: Testing framework
  • setuptools: Packaging and build tool

Contributing

Local Development

  1. Clone the repository:
    git clone https://github.com/yrangana/Sudoku-Solver-Core.git
  2. Install dependencies for development:
    pip install -e .[dev]
  3. Run tests to verify:
    pytest

Package Installation

  • Install the package in other projects using:
    pip install git+https://github.com/yrangana/Sudoku-Solver-Core.git@main

License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgements

  • Thanks to the open-source community for Python and Sudoku solving resources.

About

Core solving logic and utilities for Sudoku Solver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published