Got the algorithm to check for words basically correct.

It tests fine for "box", but hasn't been thoroughly tested for other
cases.