Programming Diversions Puzzle

by Jason Menard

As a new feature of the JavaRanch Newsletter, and to go along with our new Programming Diversions forum, we will be offering a monthly programming puzzle. Here we now present to you the first of hopefully many such puzzles. Enjoy!

WordSearch

Given any N X N grid of letters (where N > 0, N <= 100), and any set of words which may be found in the grid, write a program to find and display the starting and ending grid coordinates for each word. The top left corner of the grid is [0,0] (row 0, col 0), and the bottom right corner of the grid is [N,N].

You may input the grid of letters and the words in the manner of your own choosing. Words in the grid may be found oriented in any direction within the grid (vertical, horizontal, reverse-horizontal, reverse-diagonal-up, diagonal down, etc...).

Use the following grid and list of words to test your code.

xbcbdjwgpmpcfsh
avijureeroltfha
bdsheriffnamnev
lsuraibvoikoist
iakpffrsngtoshr
zhdanosourzsrea
eicnuludnexerwn
rednetrabvasbec
mldoarahcdwyvrh
auyjvroosendetl
pkypuiaciornede
sitemapvitralsv
rafnopekaminiui
umlksreyejmlpir
pgetwdmpevitood


javaranch
moose
bartender
sheriff
drivel
reviews
uml
threads
jdbc
roundup
You can discuss this puzzle and post your results in the Programming Diversions forum here.