A solution in C (162 Characters):
This makes use of the fact that player one value (1) and player two value (2) have independent bits set. Therefore, you can bitwise AND the values of the three test boxes together-- if the value is nonzero, then all three values must be identical. In addition, the resulting value == the player that won.
Not the shortest solution so far, but the best I could do:
void fn(){
int L[]={1,0,1,3,1,6,3,0,3,1,3,2,4,0,2,2,0};
int s,t,p,j,i=0;
while (s=L[i++]){
p=L[i++],t=3;
for(j=0;j<3;p+=s,j++)t&=b[p];
if(t)putc(t+'0',stdout);}
}
A more readable version:
void fn2(void)
{
// Lines[] defines the 8 lines that must be tested
// The first value is the "Skip Count" for forming the line
// The second value is the starting position for the line
int Lines[] = { 1,0, 1,3, 1,6, 3,0, 3,1, 3,2, 4,0, 2,2, 0 };
int Skip, Test, Pos, j, i = 0;
while (Skip = Lines[i++])
{
Pos = Lines[i++]; // get starting position
Test = 3; // pre-set to 0x03 (player 1 & 2 values bitwise OR'd together)
// search each of the three boxes in this line
for (j = 0; j < 3; Pos+= Skip, j++)
{
// Bitwise AND the square with the previous value
// We make use of the fact that player 1 is 0x01 and 2 is 0x02
// Therefore, if any bits are set in the result, it must be all 1's or all 2's
Test &= b[Pos];
}
// All three squares same (and non-zero)?
if (Test)
putc(Test+'0',stdout);
}
}