function module_edit() { global $SMARTY, $_GET; $solution = get_solution($_GET['nr']); $SMARTY->assign('solution', $solution); $SMARTY->display('module:help:edit.html'); }
<?php $status = array('parent' => -1, '8' => 8, '5' => 0, '3' => 0, 'end' => false, 'from' => -1, 'to' => -1, 'move' => -1); $status_tree = array($status); $begin_index = 0; $finish = false; while (!$finish) { build_status_tree($status_tree, $begin_index, $finish); } $solution = get_solution($status_tree); output_solution($solution, $status_tree); function build_status_tree(&$status_tree, &$begin_index, &$finish) { $begin = $begin_index; $end = count($status_tree); $begin_index = count($status_tree); for ($i = $begin; $i < $end; $i++) { if ($status_tree[$i]['end']) { continue; } move($status_tree, $i, '8', '5'); move($status_tree, $i, '8', '3'); move($status_tree, $i, '5', '8'); move($status_tree, $i, '5', '3'); move($status_tree, $i, '3', '8'); move($status_tree, $i, '3', '5'); } if (count($status_tree) == $end) { $finish = true; } }