We had a pretty poor turnout this time around, only four entries. However, they were all top notch programmers and certainly submitted interesting code. Here are the results (the code posted may not look the same as in my tests):

Salem

-----

Correct at 330 bytes

Code:#define R return s #define C const char #define I int #define L(a,b) for(r=a;r<b&&!s;r++)for(c=a;c<b&&!s;c++)I f(C**t,C*w,I*i,I y,I x){I r,c,s=1;if(!*w)R;s--;if((x|y)<0||y>4||x>4||*w!=t[y][x])R;i[0]=i[1]=-1;L(-1,2)if(r |c)s=f(t,w+1,i+2,y+r,x+c);if(s){*i++=y;*i=x;}R;}I wordSearch(C**t,C*w,I*i){I r,c,s=0;L(0,5)s=f(t,w,i,r,c);R;}

Sang-drax

---------

Correct at 361 bytes.

Code:#include <string.h> int wordSearch(const char**T,const char*O,int*I){int H=strlen(T[0]),W=0,X=0,Y,x,y,d,f,F,i;const char*w;while(strlen(T[++W])>0);for(;X<W;++X)for(Y=0;Y<H;++Y)for(d=-1;d<=1;++d)for (f=-1;f<=1;++f)if(d||f){w=O;x=X;y=Y;F=1;i=0;while(*w){if(x<0||x>W||y<0||y>H){F=0; break;}if(*w++!=T[x][y])F=0;I[i++]=x;I[i++]=y;x+=d;y+=f;}if(F)return 1;}return 0;}

Magos

-----

Correct in 3 of 6 tests, 532 bytes.

Code:#include <string> #define r return typedef const char* c;typedef int i;i S,X,Y,*I,v=0;c w,*T; i R(i C,i X,i Y,i x,i y){if(w[C]=='\0')r 1;if(X+x<0||X+x>=S||Y+y<0||Y+y>=S)r 0;if(T[X+x][Y+y]==w[C]){if(R(C+1,X+x,Y+y,x,y)==1){I[C*2]=X+x;I[C*2+1]=Y+y;r 1;}}r 0;} i W(c*t,c V,i*n){S=strlen(t[0]);w=V;I=n;T=t;for(i y=0;y<S;y++){for(i x=0;x<S;x++){if(t[x][y]==w[0]){v+=R(1,x,y,1,1);v+=R(1,x,y,1,0);v+=R(1,x,y,1,-1);v +=R(1,x,y,0,1);v+=R(1,x,y,0,-1);v+=R(1,x,y,-1,1);v+=R(1,x,y,-1,0);v+=R(1,x,y,-1,- 1);if(v>0){I[0]=x;I[1]=y;r 1;}}}}r 0;}

Swoopy

------

Correct at 477 bytes.

And my test code:Code:int wordSearch(const char **tab,const char *word,int *indices){int r,c,k,x,y,i,m,n;int d[8][2]={-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};for(r=0;tab[r][0];r++)for(c=0;tab [r][c];c++)if(tab[r][c]==*word)for(i=0;i<8;i++){n=0;indices[n++]=r;indices[n++]=c ;m=1;for(x=r+d[i][0],y=c+d[i][1],k=1;word[k]&&x!=-1&&y!=-1&&tab[x][0]&&tab[x][y]; x+=d[i][0],y+=d[i][1],k++){if(tab[x][y]!=word[k])m=0;indices[n++]=x;indices[n++]= y;}if(m&&!word[k]){indices[n]=-1;return 1;}}*indices=-1;return 0;}

The winner is Salem! Congratulations!Code:#include <stdio.h> #include <string.h> void showWord(const char **wordTable, const int *indices) { while (*indices != -1) { putchar(wordTable[*indices][*(indices + 1)]); indices += 2; } } void doTest(const char *word, int *indices, int size) { const char *tab[] = { "abcde", "babef", "taehc", "eetrh", "sfghi", "" }; int i; for (i = 0; i < size; i++) indices[i] = -1; if (wordSearch(tab, word, indices) != 0) { printf("%s == ", word); showWord(tab, indices); } else puts("FAILED"); } int main(void) { int indices[11]; doTest("cat", indices, 11); doTest("bat", indices, 11); doTest("abe", indices, 11); doTest("cheat", indices, 11); doTest("bet", indices, 11); doTest("set", indices, 11); return 0; }