<?php require_once "SudokuMapReader.php"; require_once "Shebang.php"; require_once "SudokuGrid.php"; require_once "SudokuSolver.php"; $mapreader = new SudokuMapReader(); $ret = $mapreader->Load("Grille.txt"); if ($ret == false) { return false; } $grid = new SudokuGrid(); $grid->Init($mapreader->GetGrid()); echo "Solving <br />"; $grid->ShowGrid(); $solver = new SudokuSolver(); $solver->Solve($grid); echo "<br />"; echo "Solved: <br />"; $grid->ShowGrid();
$input = $_POST; // Temporary Variable to store all validated and escaped data $input_checked = array(); // Validate data foreach ($_POST as $square => $value) { // Checks if there is any non numeric values if (!is_numeric($value) && !empty($value)) { die('Only numbers are allowed!'); } // Turns all HTML chars into HTML entity format $input_checked[$square] = htmlentities($value); } // Reassign corrected and verified input to $input varaible. Deleting temporary variable $input = $input_checked; unset($input_checked); $solver = new SudokuSolver($input); $m1 = microtime(true); $solver->solve2(); echo 'Total time: ' . (microtime(true) - $m1) . '<br>'; echo 'setRows.. time: ' . $solver->time1 . '<br>'; echo $solver->_deep; } /** * SudokuSolver class */ class SudokuSolver { // Array of all the squares ($id => $value) protected $_squares; // Original inputted values ($id => $value) protected $_orig;