/** * valid game * @param null $size * @param $matrix * @param $items_string */ public static function hwdoku_valid_game($size, $matrix, $items_string) { #$size = self::getSize(); //get sudoku size $matrix = unserialize($matrix); #$items_string=$_GET['items_string']; $items = explode(',', $items_string); $game1 = new HQ_Sudoku($size); $game1->grid = $matrix; $valid = 1; foreach ($items as $v) { $item = explode(':', $v); $ij = explode('-', $item[0]); $game1->set_item($ij[0], $ij[1], $item[1]); } foreach ($items as $v) { $item = explode(':', $v); $ij = explode('-', $item[0]); if (!$game1->valid_item($ij[0], $ij[1], $item[1])) { $valid = 0; break; } } echo '<textarea>' . $valid . '</textarea>'; }
echo $i . '-' . $j . '=>' . $item_value; $game1->grid = $matrix; $game1->set_item($i, $j, $item_value); $done = $game1->is_full_matrix() ? '*[DONE]' : ''; echo '<textarea>' . $item_value . '*' . $game1->matrix_string() . $done . '</textarea>'; } elseif ($_GET['do'] == 'valid_game') { $matrix = unserialize($_GET['matrix']); $items_string = $_GET['items_string']; $items = explode(',', $items_string); $game1 = new HQ_Sudoku($size); $game1->grid = $matrix; $valid = 1; foreach ($items as $v) { $item = explode(':', $v); $ij = explode('-', $item[0]); $game1->set_item($ij[0], $ij[1], $item[1]); } foreach ($items as $v) { $item = explode(':', $v); $ij = explode('-', $item[0]); if (!$game1->valid_item($ij[0], $ij[1], $item[1])) { $valid = 0; break; } } echo '<textarea>' . $valid . '</textarea>'; } ?> <?php if (isset($game)) {