Esempio n. 1
0
function print_power_sets($arr)
{
    echo "POWER SET of [" . join(", ", $arr) . "]<br>";
    foreach (power_set($arr) as $subset) {
        print_array($subset);
    }
}
Esempio n. 2
0
 function power_set($array){
 	if(!$array) return array($array);
 	$a = array();
 	foreach( power_set( array_slice( $array, 1) ) as $i ){
 		$return[] = $i;
 		$return[] = array_merge( array( $array[0] ), $i);
 	}
 	return $return;
 }
function power_perms($arr)
{
    $power_set = power_set($arr);
    $result = array();
    foreach ($power_set as $set) {
        $perms = perms($set);
        $result = array_merge($result, $perms);
    }
    return $result;
}