2017 © Pedro Peláez
 

library sudoku

Small library to solve sudoku

image

eugeniypetrov/sudoku

Small library to solve sudoku

  • Monday, March 24, 2014
  • by EugeniyPetrov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Sudoku

Sudoku solver library. Example of usage:, (*1)

use \EugeniyPetrov\Sudoku;

$sudoku = new Sudoku([
    [0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0],
]);

$sudoku->solve();

echo $sudoku;

The result will be, (*2)

1   2   3   4   5   6   7   8   9   
4   5   6   7   8   9   1   2   3   
7   8   9   1   2   3   4   5   6   
2   3   1   6   7   4   8   9   5   
8   7   5   9   1   2   3   6   4   
6   9   4   5   3   8   2   1   7   
3   1   7   2   6   5   9   4   8   
5   4   2   8   9   7   6   3   1   
9   6   8   3   4   1   5   7   2   

Algorithm works by counting the number of possible numbers for each cell and setting the only possible numbers in their places until sudoku is not solved. It there are no any cells with only possible values trying to recursively solve sudoku with each possible values., (*3)

Throws UnableToSolveException if sudoku have no solutions., (*4)

The Versions

24/03 2014

dev-master

9999999-dev

Small library to solve sudoku

  Sources   Download

The Requires

  • php >=5.4