Original Post
Hi, i''m trying to develop a word search algorithm that searches a 2D Matrix horizontally and vertically for certain words.
ASDFGLAF
AJADJLKD
JUVUAJAA
JKEKJDLK
As an example I want to see if this matrix contains the word "DAVE"
My best guess is the algorithm would be similar to this:
For each letter X,Y in the matrix
check to see if X,Y matches I in the target word
if it matches check X+1,Y to see if it matches I+1
if matches
compair X+2,Y with I+2
...
else
check X,Y+1 with I+1
if matches
check X,Y+2 with I+2
.... etc
Is there a better way to do this? This seems rather brute.