Tic Tac Toe Scoreboard
Rank Username Score
1 primo 1000 (153 B)
2 JWvdVeer 933 (164 B)
3 Epower 475 (322 B)
4 garas 417 (367 B)
5 scottholdren 410 (373 B)
6 holyshart 363 (421 B)
Recent Activity
Username Bytes Time ago Result
primo 153 November 17 2011, 00:07:55
primo 154 November 16 2011, 22:19:10
jth 75 February 18 2011, 20:57:31
JWvdVeer 153 February 09 2011, 18:29:11
JWvdVeer 153 February 09 2011, 18:28:28
JWvdVeer 157 February 09 2011, 18:26:21
JWvdVeer 157 February 09 2011, 18:26:16
JWvdVeer 153 February 09 2011, 18:26:16
JWvdVeer 153 February 09 2011, 18:25:37
JWvdVeer 153 February 09 2011, 18:25:29
JWvdVeer 153 February 09 2011, 18:25:25
JWvdVeer 153 February 09 2011, 18:06:18
JWvdVeer 153 February 09 2011, 18:06:16
JWvdVeer 153 February 09 2011, 18:06:13
JWvdVeer 158 February 09 2011, 17:56:48

Challenge: Tic Tac Toe

Challenge information

Challenge Type Public
Challenge Status Open
Constant name BOARDS
Trim method Full trim
Rating [ up ] [ down ]

Instructions

You will be given random filled Tic Tac Toe boards.

'X' always starts.

Figure out who wins of 'X' or 'O'. If there is a tie, you print 'None'.

Example

Show/hide Input
O|X|O
X|X|O
O|X|X

O|X|X
X|O|X
 |O|O

X|O|X
O| |X
O|X|O
Show/hide Output
X
O
None

Comments

Show/hide comments (0)

Submissions

153 bytes (ver. 2) by primo Show / Hide
<?for($b=BOARDS;$b[$n];$n+=19){for($s=~;$c=$s[$i];${$i++%8}|=$b[$n+ord($c)])$$i=H;for(;--$i;)ereg($$i,OX,$c);echo$c[0]?:None,~;}
154 bytes (ver. 1) by primo Show / Hide
<?for($b=BOARDS,$s=~;$b[$n];$n+=19){for(;$c=$s[$i];${$i++%8}|=$b[$n+ord($c)])$$i=H;for(;--$i;)ereg($$i,OX,$c);echo$c[0]?:None,~;}
164 bytes (ver. 39) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){$d=None;for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)$m.$m!=$a[$l+$k].$a[$l+2*$k]|($j!=4&$k==4)|($k==2&&$j%3)?:$d=$m;echo$d.~;}
167 bytes (ver. 36) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){$d=None;for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3))$d=$m;echo"$d
"
;}
167 bytes (ver. 38) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){$d=None;for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3))$d=$m;echo"$d
"
;}
169 bytes (ver. 17) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19,$d='None'){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3))$d=$m;echo"$d
"
;}
169 bytes (ver. 21) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19,$d='None'){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3))$d=$m;echo"$d
"
;}
169 bytes (ver. 33) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){$d='None';for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3))$d=$m;echo"$d
"
;}
169 bytes (ver. 34) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){$d='None';for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3))$d=$m;echo"$d
"
;}
169 bytes (ver. 35) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){$d='None';for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3))$d=$m;echo"$d
"
;}
170 bytes (ver. 19) by JWvdVeer Show / Hide
<?for($a=BOARDS,$b=~;$a[$i];$i+=19,$d='None'){for($j=0;$j<24;)if($a[$i+$b[$j++]*2]==($m=$a[$i+$b[$j++]*2])&$m==$a[$i+$b[$j++]*2])$d=$m;echo"$d
"
;}
170 bytes (ver. 20) by JWvdVeer Show / Hide
<?for($a=BOARDS,$b=~;$a[$i];$i+=19,$d='None'){for($j=0;$j<24;)if($a[$i+$b[$j++]*2]==($m=$a[$i+$b[$j++]*2])&$m==$a[$i+$b[$j++]*2])$d=$m;echo"$d
"
;}
171 bytes (ver. 30) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19,$d='None'){for($j=18;$j;)for($m=$a[$l=$i+$j-=2]&,$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3))$d=$m;echo"$d
"
;}
171 bytes (ver. 32) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){$d='None';for($j=18;$j;)for($m=$a[$l=$i+$j-=2]&,$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3))$d=$m;echo"$d
"
;}
178 bytes (ver. 14) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3)){echo"$m
"
;continue 3;}echo'None
'
;}
178 bytes (ver. 15) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3)){echo"$m
"
;continue 3;}echo'None
'
;}
179 bytes (ver. 7) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m==$a[$l+$k]&$m==$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3)){echo"$m
"
;continue 3;}echo'None
'
;}
179 bytes (ver. 8) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m==$a[$l+$k]&$m==$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3)){echo"$m
"
;continue 3;}echo'None
'
;}
183 bytes (ver. 9) by JWvdVeer Show / Hide
<?for($a=BOARDS,$b=~;$a[$i];$i+=19){for($j=0;$j<24;){if($a[$i+$b[$j++]*2]==($m=$a[$i+$b[$j++]*2])&$m==$a[$i+$b[$j++]*2]){echo"$m
"
;continue 2;}}echo'None
'
;}
183 bytes (ver. 10) by JWvdVeer Show / Hide
<?for($a=BOARDS,$b=~;$a[$i];$i+=19){for($j=0;$j<24;){if($a[$i+$b[$j++]*2]==($m=$a[$i+$b[$j++]*2])&$m==$a[$i+$b[$j++]*2]){echo"$m
"
;continue 2;}}echo'None
'
;}
184 bytes (ver. 12) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==trim($a[$l+$k]).$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3)){echo"$m
"
;continue 3;}echo'None
'
;}
184 bytes (ver. 13) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m.$m==trim($a[$l+$k]).$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3)){echo"$m
"
;continue 3;}echo'None
'
;}
185 bytes (ver. 11) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$k-=2;)if($m==trim($a[$l+$k])&$m==$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3)){echo"$m
"
;continue 3;}echo'None
'
;}
186 bytes (ver. 4) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$m!=~&&$k-=2;)if($m.$m==$a[$l+$k].$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3)){echo"$m
"
;continue 3;}echo'None
'
;}
187 bytes (ver. 3) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$m!=~&&$k-=2;)if($m==$a[$l+$k]&$m==$a[$l+2*$k]&($k!=4|$j==4)&!($k==2&&$j%3)){echo"$m
"
;continue 3;}echo'None
'
;}
193 bytes (ver. 2) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;$m!=~&&$k-=2;)if($m==$a[$l+$k]&&$m==$a[$l+2*$k]&&($k!=4||$j==4)&&($k!=2||!($j%3))){echo"$m
"
;continue 3;}echo'None
'
;}
195 bytes (ver. 1) by JWvdVeer Show / Hide
<?for($a=BOARDS;$a[$i];$i+=19){for($j=18;$j;)for($m=$a[$l=$i+$j-=2],$k=10;trim($m)&&$k-=2;)if($m==$a[$l+$k]&&$m==$a[$l+2*$k]&&($k!=4||$j==4)&&($k!=2||!($j%3))){echo"$m
"
;continue 3;}echo'None
'
;}
322 bytes (ver. 4) by Epower Show / Hide
<?foreach(explode("

"
,BOARDS)as$b){for($i=0;$i<5;$i+=2)if($b[$i]==$b[$i+6]&&$b[$i]==$b[$i+12]){echo$b[$i],"
"
;continue 2;}for($i=0;$i<13;$i+=6)if($b[$i]==$b[$i+2]&&$b[$i]==$b[$i+4]){echo$b[$i],"
"
;continue 2;}if($b[0]==$b[8]&&$b[0]==$b[16])echo$b[0],"
"
;elseif($b[4]==$b[8]&&$b[4]==$b[12])echo$b[4],"
"
;else echo"None
"
;}
367 bytes (ver. 4) by garas Show / Hide
<?$c='([XO ])';$r="$c\|$c\|$c";foreach(split('

'
,BOARDS)as$b){if(preg_match('#(X|O)\|\1\|\1#',$b,$m)){echo"$m[1]
"
;continue;}preg_match("#$r
$r
$r#",$b,$m);for($i=3;$i--;)if($m[$i+1]==$m[$i+4]&&$m[$i+4]==$m[$i+7]){echo$m[$i+1].'
'
;continue 2;}if($m[1]==$m[5]&&$m[5]==$m[9]){echo$m[1].'
'
;continue;}if($m[3]==$m[5]&&$m[5]==$m[7]){echo$m[3].'
'
;continue;}echo'None
'
;}
373 bytes (ver. 3) by scottholdren Show / Hide
<?foreach(split("\n",BOARDS)as$z)foreach(split("\n",$z)as$l)if(!$l)++$c;else$t[$c][]=split("\|",$l);foreach($t as$g){$w=None;for($i=0;$i<3;$i++){if($g[$i][0]==$g[$i][1]&&$g[$i][1]==$g[$i][2])$w=$g[$i][1];if($g[0][$i]==$g[1][$i]&&$g[1][$i]==$g[2][$i])$w=$g[1][$i];}if(($g[0][0]==$g[1][1]&&$g[1][1]==$g[2][2])||($g[0][2]==$g[1][1]&&$g[1][1]==$g[2][0]))$w=$g[1][1];echo"$w
"
;}
401 bytes (ver. 1) by garas Show / Hide
<?$c='([XO ])';$r="$c\|$c\|$c";foreach(split('

'
,BOARDS)as$b){preg_match("#$r
$r
$r#",$b,$m);for($i=3;$i--;)if($m[$i*3+1]==$m[$i*3+2]&&$m[$i*3+2]==$m[$i*3+3]){echo$m[$i*3+1].'
'
;continue 2;}for($i=3;$i--;)if($m[$i+1]==$m[$i+4]&&$m[$i+4]==$m[$i+7]){echo$m[$i+1].'
'
;continue 2;}if($m[1]==$m[5]&&$m[5]==$m[9]){echo$m[1].'
'
;continue;}if($m[3]==$m[5]&&$m[5]==$m[7]){echo$m[3].'
'
;continue;}echo'None
'
;}
421 bytes (ver. 2) by holyshart Show / Hide
<?function x($a){return $a[0]!=''&&count(array_unique($a))==1;}$i=explode("\n",BOARDS);for($j=$d=0;$j<=$k=count($i);$j++){$b=$i[$j];if(!empty($b))$c[$d++]=explode('|',$b);elseif($d){$d=0;$s='None';for($e=0;$e<3;$e++){if(x(array($c[0][$e],$c[1][$e],$c[2][$e]))) $s=$c[0][$e];if(x($c[$e])) $s=$c[$e][0];}if(x(array($c[0][0],$c[1][1],$c[2][2]))) $s=$c[0][0];if(x(array($c[0][2],$c[1][1],$c[2][0]))) $s=$c[2][0];echo"$s\n";}}
455 bytes (ver. 1) by holyshart Show / Hide
<?$d=0;$i=explode("\n",BOARDS);$c=array();for($j=0;$j<=count($i);$j++){if($j==count($i))$b='';else$b=$i[$j];if(!empty($b)){$c[$d]=explode('|',$b);$d++;}elseif($d!=0){$d=0;$s="None\n";for($e=0;$e<3;$e++){if($c[0][$e]==$c[1][$e]&&$c[2][$e]==$c[1][$e]){$s=$c[0][$e]."\n";}if(count(array_unique($c[$e]))==1){$s=$c[$e][0]."\n";}}if($c[0][0]==$c[1][1]&&$c[1][1]==$c[2][2]){$s=$c[0][0]."\n";}if($c[0][2]==$c[1][1]&&$c[1][1]==$c[2][0]){$s=$c[2][0]."\n";}echo$s;}}
478 bytes (ver. 1) by scottholdren Show / Hide
<?

$b
=preg_split("/\+\n\+/",BOARDS);
foreach(
$b as$z){
    
$t=array();
    foreach(
split("\n",$z)as$l){
        if(!
$l)++$c;
        else
$t[$c][]=preg_split("/ *\| */",$l);
    }
}
foreach(
$t as $g)
{
    
$w=None;
    for(
$i=0;$i<3;$i++)if($g[$i][0]==$g[$i][1]&&$g[$i][1]==$g[$i][2])$w=$g[$i][1];
    for(
$i=0;$i<3;$i++)if($g[0][$i]==$g[1][$i]&&$g[1][$i]==$g[2][$i])$w=$g[1][$i];
    if(
$g[0][0]==$g[1][1]&&$g[1][1]==$g[2][2])$w=$g[1][1];
    if(
$g[0][2]==$g[1][1]&&$g[1][1]==$g[2][0])$w=$g[1][1];
    print
"$w\n";
}