Download the PHP package xeeeveee/sudoku without Composer

On this page you can find all versions of the php package xeeeveee/sudoku. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sudoku

Build Status

PHP Sudoku Generator & Solver

A PHP Sudoku generate and solver implemented via a bruteforce backtracking algorithm.

Installation

Install via composer with php composer require xeeeveee/sudoku:*

Usage

TL;DR full examples

Generator

Once an instance has been initialized you can generate a new sudoku puzzle by calling the generatePuzzle() method as below:

You can also specify the difficulty of the puzzle to generate by passing an integer between 0 and the maximum number of cells in the puzzle (81 for a 3*3 $cellSize). This represents how many of the cells will be pre-populated in the puzzle. For example, the below snippet should generate a puzzle with 25 of the cells pre-populated.

Solver

Solving a puzzle is as simple as calling the solve() method on the object, which will return either true or false depending on the outcome, see below for example:

You can use the isSolved() method to check if the object contains a solved solution, and use the getSolution method to retrieve the array, a more complete example might look like the below:

Puzzle & solution format

A standard ($cellSize 3) puzzle and solution is represented as 3 dimensional array, effectively 9 ($cellSize * $cellSize) rows with the same number of columns. Blank values are represented as 0. The definition for a complete empty (`$cellSize 3) puzzle or solution would look like the below:

Performance notice

Due to the nature of the algorithm used to generate and solve puzzles, the execution time for these commands increases exponentially as the $cellSize used is increased, puzzles with a $cellSize exceeding 4 will take an exceptionally long time to solve on average.

Available methods

integer getCellSize() Returns cell size of the puzzle.

boolean setCellSize() Sets the cell size of the puzzle. Note - This will reset the $puzzle and $solution properties on the object.

integer getGridSize() Returns cell size of the puzzle. Note - This is calculated based on the $cellSize property.

array getPuzzle() Returns the puzzle array.

boolean setPuzzle(array $puzzle = []) Sets the puzzle array - If the $puzzle parameter is omitted or an invalid array structure is pass, a empty grid will be generated and false will be returned. Note - Setting the puzzle always resets the solution to an empty grid.

array getSolution() Returns the solution array.

boolean setSolution(array $solution) Sets the solution, if the $solution parameter supplied is an invalid format false is returned and the solution is not modified.

boolean solve() Attempts to solve the puzzle.

boolean isSolved() Returns true if a the solution is valid for the current puzzle.

boolean isSolvable() Returns true if the puzzle is solvable - This is significantly quicker then actually solving the puzzle.

boolean generatePuzzle($cellCount = 15) Generates a new puzzle, the $cellCount parameter specifies how many cells will be pre-populated, effectively manipulating the difficulty. 0 - 81 are valid values for $cellCount if any other value is supplied false is returned. Note - Generating a puzzle always resets the solution to an empty grid.


All versions of sudoku with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package xeeeveee/sudoku contains the following files

Loading the files please wait ....