- array_sum: documentation ( source)
<?php
$in = 8;
$count = 0;
function trace($x, $y, $z, $steps) {
global $count;
if ($steps == 0) {
if ($x == 0 && $y == 0 && $z == 0) {
$count++;
}
return;
}
for($i = $x-1; $i <= $x+1; $i++) {
for($j = $y-1; $j <= $y+1; $j++) {
for($k = $z-1; $k <= $z+1; $k++) {
if (
array_sum(array($i, $j, $k)) !== 0
|| ($i == $x && $j == $y && $k == $z)
) {
continue;
}
trace($i, $j, $k, $steps-1);
}
}
}
}
trace(0, 0, 0, $in);
echo $count;
This script was stopped while abusing our resources