https://github.com/coenmooij/sudoku
Library for generating, validating, solving sudoku puzzles
https://github.com/coenmooij/sudoku
library php7 sudoku
Last synced: about 1 year ago
JSON representation
Library for generating, validating, solving sudoku puzzles
- Host: GitHub
- URL: https://github.com/coenmooij/sudoku
- Owner: coenmooij
- License: mit
- Created: 2017-10-27T11:37:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-08T11:29:12.000Z (over 7 years ago)
- Last Synced: 2025-02-10T11:09:47.349Z (over 1 year ago)
- Topics: library, php7, sudoku
- Language: PHP
- Size: 75.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://scrutinizer-ci.com/g/coenmooij/sudoku/?branch=master) [](https://scrutinizer-ci.com/code-intelligence) [](https://travis-ci.org/coenmooij/sudoku)
# sudoku
Library for generating, validating, solving sudoku puzzles
## Composer
To use this package, simply run `composer require coenmooij/sudoku`.
## Usage
### SudokuService
Exposes the main functionality of the library in a service.
### Solvers
#### BacktrackSolver
Solves any solvable grid using an informed backtrack algorithm. Throws an `UnsolvableException` if it fails.
#### SimpleSolver
Solves the grid using only row, column and block checks. Will return the (partially) completed `Grid`.
### Generators
#### SolutionGenerator
Generates a complete `Grid`
#### PuzzleGenerator
Creates a puzzle based on a complete `Grid` and a `Difficulty`
Difficulty ranges from 1-5 and can be accessed by a constant. e.g. `Difficulty::EASY`.
#### HintGenerator
From a grid it creates hints. It returns locations which can be solved by row, column & block checks.
You can either get a random one or all of them.
### GridSerializer
`GridSerializer` is a simple serializer that turns a 81 character string into a `Grid` and back.
e.g. `642957138719843652538126794483712569976538421125694387294361875357489216861275943`
Empty values will be serialized to `0` but the deserializer also accepts alphabetical characters as empty values.
### Validator
#### DigValidator
Helper class to see if it is 'safe' to dig out the value at a certain `Location`. It checks whether the `Grid` is still uniquely solvable.
#### GridValidator
Simple utility class to check if all (row, column and block) constraints are still met.