PHP Classes

PHP Sudoku Solver: Generate and solve Sudoku puzzles

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 211 All time: 8,335 This week: 89Up
Version License PHP version Categories
sudoku-solver 1.0.0GNU Lesser Genera...5Algorithms, PHP 5, Games


This class can senerate and solve Sudoku puzzles.

It takes a parameter that defines the size of the gride of a Sudoku puzzle that it will generate.

The class can render the generated Sudoku puzzle in an HTML table.

The class can also solve the puzzle determining the sequence of moves necessary to complete it.

Picture of Samuel Adeshina
  Performance   Level  
Name: Samuel Adeshina is available for providing paid consulting. Contact Samuel Adeshina .
Classes: 19 packages by
Country: Nigeria Nigeria
Age: 25
All time rank: 5252 in Nigeria Nigeria
Week rank: 101 Up5 in Nigeria Nigeria Down
Innovation award
Innovation award
Nominee: 7x

Winner: 1x


    Description: This test file stores the current game play (an array actually)
                    In a session variable, you could decide to use cookies,
                    html5 state saving or any method of keeping the current data in memory
                    that works best for you.

    Author: Samuel Adeshina

    Dependency: The sudoku.php class file bundled together with this file is required
                    run the test.php file in a browser to get a 'visual instance' of how this works
    if (!isset(
$_GET["loc"]) || !isset($_GET["sudokutype"]) || !isset($_GET["startover"])
$_GET["sudokutype"] == '' || $_GET["startover"] == '' || $_GET["loc"] == ''
$_GET["sudokutype"] = 9;
$_GET["startover"] = "false";
$_GET["loc"] = "a1";
$loc = $_GET["loc"];
$startover = $_GET["startover"];
$sudokType = $_GET["sudokutype"];
$mySudoku = new sudoku($sudokType); //Instantiating the sudoku class with a grid size of whatever is in the variable: $sudokType
if ($startover == "true")
        if (isset(
    if (!isset(
$_SESSION["currentmoves"]) || !is_array($_SESSION["currentmoves"]))
$_SESSION["currentmoves"] = $mySudoku->_populateSubs(); //Populating the board
//echo "<center>Number Of Iterations For Current Play: ";
$_SESSION["currentmoves"] = $mySudoku->_solveSudoku($loc, $_SESSION["currentmoves"]); //Generates the value of the grid with a name of : $loc ($loc could be a1, c4, i8 and so on)
    if (
in_array(-1, $_SESSION["currentmoves"]))
$index = array_search(-1, $_SESSION["currentmoves"]);
$_SESSION["currentmoves"][$index] = '--'; //displays a custom character(s) in the grid incase the value cant be determined through brute force

  Files folder image Files  
File Role Description
Accessible without login Plain text file jquery.js Data JQuery Library needed only fr testing
Accessible without login Plain text file LICENSE Lic. License File
Plain text file sudoku.php Class Main Class File
Accessible without login Plain text file test.php Aux. Contains A Sample Interface Design For A Working Sudoku Game
Accessible without login Plain text file testProcessor.php Example Contains the Logic for the test file

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,335
This week:89Up