#define N 5
char boggle[N][N+1]={
{"URLPM"},
{"XPRET"},
{"GIAET"},
{"XTNZY"},
{"XOQRS"}
};
int wordN = 6;
bool hasWord(int x, int y, int depth, const char* word){
if(x<0 || x>=N || y <0 || y >= N){
return false;
}
bool hasWordValue = boggle[x][y]==word[depth];
if(!hasWordValue) return hasWordValue;
if(depth==wordN-1) return hasWordValue;
if(hasWord(x+1,y+1,depth+1,word)){return true;}
if(hasWord(x+1,y-1,depth+1,word)){return true;}
if(hasWord(x-1,y-1,depth+1,word)){return true;}
if(hasWord(x-1,y+1,depth+1,word)){return true;}
if(hasWord(x+1,y,depth+1,word)){return true;}
if(hasWord(x-1,y,depth+1,word)){return true;}
if(hasWord(x,y+1,depth+1,word)){return true;}
if(hasWord(x,y-1,depth+1,word)){return true;}
return false;
}
int main(){
char word[10]="PRETTY";
if(hasWord(1,1,0,word)){
printf("%s exists
",word);
}
return 0;
}