\n"; print "\n"; for ($row=0;$row<3;$row++) { print ""; for ($col=0;$col<3;$col++) { $idx=$row*3+$col; printf(""; } print "\n"; } if ($rw) print "\n"; print "
"; if ($rw) print "Input:"; else printf("Step #%d",$tables+1); print "
\n"; $tables++; } $input=array(); $used=array(); $filled=0; $tables=0; for ($idx=0;$idx<9;$idx++) { $s=$_GET[sprintf("%d",$idx)]; if (!strlen($s)) continue; $x=ord($s)-ord("0"); if (strlen($s)!=1 || $x<1 || $x>9 || isset($used[$x])) { printf("

WARNING: Digit at row %d, column %d was %s, erased!

\n",1+$idx/3,1+$idx%3, ($used[$x] ? "repeated" : "invalid")); continue; } $input[$idx]=$x; $used[$x]=1; $filled++; } // Both popen() and proc_open() require: /bin/sh if ($filled==9 && !is_executable("/bin/sh")) { print "

Current installation environment forbids the execution!

\n"; $filled=0; } if ($filled==9) { print ""; $cmd="echo -n -e '"; for ($row=0;$row<3;$row++) { for ($col=0;$col<3;$col++) { if ($col) $cmd.=" "; $cmd.=sprintf("%d",$input[$row*3+$col]); } $cmd.="\\n"; } $cmd.="' | ./Nokia61"; $cmd=popen($cmd,"r"); $idx=0; $output=array(); while (!feof($cmd)) { if (3!=fscanf($cmd,"\n %d%d%d",$output[$idx+0],$output[$idx+1],$output[$idx+2])) continue; $idx+=3; if ($idx<9) continue; print ""; if (!($tables%$tables_per_row)) print ""; $idx=0; } pclose($cmd); print "
"; table($output); print " 
\n"; print "
\n"; $input=array(); } table($input,1); if (!isset($_GET["nohtml"])) { ?>