<?php require 'sudoku.php'; $sudoku = new sudoku(); ?> <!DOCTYPE HTML> <html> <head> <title>SUDOKU GENERATOR</title> <style type="text/css"> .sudoku { margin: 0 auto; margin-top: 100px; } .inline { display: inline-block; padding: 15px; } </style> </head> <body> <div class="sudoku"> <div class="inline"> <h3>THE PUZZLE</h3> <?php $sudoku->generate(); ?> </div> <div class="inline"> <h3>THE SOLUTION</h3>
function create(&$si, &$sp, $level = 1) { for ($i = 1; $i <= 40; $i++) { $sp = new sudoku(); $theinitialposition = $sp->generatepuzzle(10, 50, $level); if (count($theinitialposition)) { break; } } if ($i > 40) { return false; } $si = new sudoku(); $si->initializepuzzlefromarray($theinitialposition); return true; }