romanpiller / sudoku
Sudoku solver
Package info
Language:HTML
Type:package
pkg:composer/romanpiller/sudoku
Requires
- php: ^8.2
- nette/di: ^3.2
Requires (Dev)
- mockery/mockery: ^1.6
- nette/tester: ^2.4
- phpstan/phpstan: ^1.12.28
- roave/security-advisories: dev-latest
- shipmonk/composer-dependency-analyser: ^1.8
- squizlabs/php_codesniffer: ^3.7
- tracy/tracy: ^2.12
This package is auto-updated.
Last update: 2026-07-04 20:12:27 UTC
README
A simple and efficient tool for solving Sudoku grids written in PHP. The package supports various output formats (text, HTML) and is ready for integration into Nette projects.
Installation
The package can be installed using Composer:
composer require romanpiller/sudoku
Requirements
- PHP 8.2 or higher
Usage
The main entry point for working with the package is SudokuFacade.
Usage Example
use RomanPiller\Sudoku\Facades\SudokuFacade; // Facade initialization (ideally via DI container) // $facade = $container->getByType(SudokuFacade::class); // If the facade is configured via DI, just call solve with the filename $result = $facade->solve( inputFilename: 'input.txt', inputDirectory: __DIR__ . '/../../examples', stdOut: true, outputFilename: 'example-hard.html', outputDirectory: __DIR__ . '/../../temp' ); if ($result) { echo "Sudoku was successfully solved."; } else { echo "Failed to solve Sudoku."; }
Input File Format
The input file should contain 81 numbers (values 0-9) separated by commas. Zero (0) represents an empty cell. Whitespace (spaces, tabs, etc.) and newlines are ignored during processing.
Example input.txt:
5,3,0,0,7,0,0,0,0,
6,0,0,1,9,5,0,0,0,
0,9,8,0,0,0,0,6,0,
8,0,0,0,6,0,0,0,3,
4,0,0,8,0,3,0,0,1,
7,0,0,0,2,0,0,0,6,
0,6,0,0,0,0,2,8,0,
0,0,0,4,1,9,0,0,5,
0,0,0,0,8,0,0,7,9
Configuration in Nette
The best way to register the package in Nette is to use the DI extension:
extensions: sudoku: RomanPiller\Sudoku\Config\Extension
Development and Testing
The project includes a set of tools for maintaining code quality:
Static Analysis (PHPStan)
composer phpstan
Code Quality Check (PHP CodeSniffer)
composer phpcodesniffer
Unit Tests (Nette Tester)
composer unit
Test Coverage
composer cover
Manual Tests
composer manual
License
This project is licensed under the MIT License.