title: Searching for a word in a grid
body: <p>I'm trying to write a function that takes a square grid of letters and given a word to find from a list of words, it searches for it horizontally, vertically or diagonally (also looking backwards in each case). I've tried writing this function in various ways with no success so was wondering if my general algorithm sounded ok and implementable.</p>
  
  <ul>
  <li><p>Return co-ordinates for everywhere the first letter of the word occurs so something like 
  <code>[row,col] = find(grid==words(2))</code> with words being the list of words and grid being the square matrix. So this would search within <code>grid</code> for the second word in <code>words</code>.</p></li>
  <li><p>For each occurrence of this letter move vertically, horizontally and diagonally in all directions for the length of the word and if last letter is that of the last letter of the word we are looking for store each character from first to the last as words in an array.</p></li>
  <li><p>Compare each of these words to the word we are looking for and if there is a match draw a line.</p></li>
  </ul>
  
  <p>Thoughts?</p>