<?php
$z[1] = array("-",0,0,0,0,0,0,0,0,0);
$z[2] = array("-",0,0,0,0,0,0,0,0,0);
$z[3] = array("-",0,0,0,0,0,0,0,0,0);
$z[4] = array("-",0,0,0,0,0,0,0,0,0);
$z[5] = array("-",0,0,0,0,0,0,0,0,0);
$z[6] = array("-",0,0,0,0,0,0,0,0,0);
$z[7] = array("-",0,0,0,0,0,0,0,0,0);
$z[8] = array("-",0,0,0,0,0,0,0,0,0);
$z[9] = array("-",0,0,0,0,0,0,0,0,0);
$s[1] = array("-",0,0,0,0,0,0,0,0,0);
$s[2] = array("-",0,0,0,0,0,0,0,0,0);
$s[3] = array("-",0,0,0,0,0,0,0,0,0);
$s[4] = array("-",0,0,0,0,0,0,0,0,0);
$s[5] = array("-",0,0,0,0,0,0,0,0,0);
$s[6] = array("-",0,0,0,0,0,0,0,0,0);
$s[7] = array("-",0,0,0,0,0,0,0,0,0);
$s[8] = array("-",0,0,0,0,0,0,0,0,0);
$s[9] = array("-",0,0,0,0,0,0,0,0,0);
$q[1] = array("-",0,0,0,0,0,0,0,0,0);
$q[2] = array("-",0,0,0,0,0,0,0,0,0);
$q[3] = array("-",0,0,0,0,0,0,0,0,0);
$q[4] = array("-",0,0,0,0,0,0,0,0,0);
$q[5] = array("-",0,0,0,0,0,0,0,0,0);
$q[6] = array("-",0,0,0,0,0,0,0,0,0);
$q[7] = array("-",0,0,0,0,0,0,0,0,0);
$q[8] = array("-",0,0,0,0,0,0,0,0,0);
$q[9] = array("-",0,0,0,0,0,0,0,0,0);
$count = 1;
while ($count <= 9)
{
$unterbrecher = 1;
$c=1;
while ($c <= 9)
{
if ($count < 4)
{
if ($c < 4) $qc = 1;
if ($c < 7 && $c > 3) $qc = 2;
if ($c > 6) $qc = 3;
}
if ($count < 7 && $count > 3)
{
if ($c < 4) $qc = 4;
if ($c < 7 && $c > 3) $qc = 5;
if ($c > 6) $qc = 6;
}
if ($count > 6)
{
if ($c < 4) $qc = 7;
if ($c < 7 && $c > 3) $qc = 8;
if ($c > 6) $qc = 9;
}
if ($count == 1 || $count == 4 || $count == 7) $qSumA = 0;
if ($count == 2 || $count == 5 || $count == 8) $qSumA = 3;
if ($count == 3 || $count == 6 || $count == 9) $qSumA = 6;
if ($c < 4) $qSumB = $c;
if ($c > 6) $qSumB = $c - 6;
if ($c > 3 && $c < 7) $qSumB = $c - 3;
$qSum = $qSumA + $qSumB;
srand((double)microtime()*1000000);
$a = rand(1,9);
if (!in_array($a, $z[$count]) && !in_array($a, $s[$c]) && !in_array($a, $q[$qc]))
{
$z[$count][$c] = $a;
$s[$c][$count] = $a;
$q[$qc][$qSum] = $a;
$c++;
}
else
{
$unterbrecher++;
if ($unterbrecher == 500)
{
$z[1] = array("-",0,0,0,0,0,0,0,0,0);
$z[2] = array("-",0,0,0,0,0,0,0,0,0);
$z[3] = array("-",0,0,0,0,0,0,0,0,0);
$z[4] = array("-",0,0,0,0,0,0,0,0,0);
$z[5] = array("-",0,0,0,0,0,0,0,0,0);
$z[6] = array("-",0,0,0,0,0,0,0,0,0);
$z[7] = array("-",0,0,0,0,0,0,0,0,0);
$z[8] = array("-",0,0,0,0,0,0,0,0,0);
$z[9] = array("-",0,0,0,0,0,0,0,0,0);
$s[1] = array("-",0,0,0,0,0,0,0,0,0);
$s[2] = array("-",0,0,0,0,0,0,0,0,0);
$s[3] = array("-",0,0,0,0,0,0,0,0,0);
$s[4] = array("-",0,0,0,0,0,0,0,0,0);
$s[5] = array("-",0,0,0,0,0,0,0,0,0);
$s[6] = array("-",0,0,0,0,0,0,0,0,0);
$s[7] = array("-",0,0,0,0,0,0,0,0,0);
$s[8] = array("-",0,0,0,0,0,0,0,0,0);
$s[9] = array("-",0,0,0,0,0,0,0,0,0);
$q[1] = array("-",0,0,0,0,0,0,0,0,0);
$q[2] = array("-",0,0,0,0,0,0,0,0,0);
$q[3] = array("-",0,0,0,0,0,0,0,0,0);
$q[4] = array("-",0,0,0,0,0,0,0,0,0);
$q[5] = array("-",0,0,0,0,0,0,0,0,0);
$q[6] = array("-",0,0,0,0,0,0,0,0,0);
$q[7] = array("-",0,0,0,0,0,0,0,0,0);
$q[8] = array("-",0,0,0,0,0,0,0,0,0);
$q[9] = array("-",0,0,0,0,0,0,0,0,0);
$count=1;
$c=1;
}
}
}
$count++;
}
echo "<font face=\"monospace\"><center>";
$cA = 1;
while ($cA <= 9)
{
$cB = 1;
while ($cB <= 9)
{
echo $z[$cA][$cB];
if ($cB == 3 || $cB == 6) echo "|";
$cB++;
}
$brech = "<br>";
if ($cA == 3 || $cA == 6) $brech = "<br>---|---|---<br>";
echo $brech;
$cA++;
}
?>