<?php
/*
*** Bruteforce algo ***
* c = first(P)
* while(c != ^)
* if valid(c, P) then output(P, c)
* c = next(P, c)
*** Variables ***
* P = problem
* c = candidate solution for P
* ^ = null data
**/
/*
* Generate the first candidate solution
**/
function first_c(&$P) {/**/}
/*
* Generate the next candidate solution based on the last.
* Returns null if there's no next candidate
**/
function next_c(&$P, $c) {/**/}
/*
* Checks if the solution candidate is valid
* Returns true of false
**/
function valid(&$c, &$P) {/**/}
/*
* Prints out the solution to the problem.
**/
function output($P, $c) {/**/}
$c = first_c($P);
while($c != null)
{
if(valid($c, $P) == true) output($P, $c);
$c = next_c($P, $c);
}
?>