A popular word game involves finding words from a grid of randomly generated letters. Words must be at least three letters long and formed from adjoining letters. Letters may not be reused and it is valid to move across diagonals. As an example, consider the 4x4 grid of letters below.
A B C D
E F G H
I J K L
M N O P
The word "FAB" is valid (letters in the upper left corner) and the word "KNIFE" is valid. The word "BABE" is not valid because the "B" may not be reused. The word "MINE" is not valid because the "E" is not adjacent to the "N".
Write a program that implements the above problem. The program should randomly select letters for the board. Either place a "U" next to a "Q" or to treat "QU" as a single letter. The program should show the dice tray and ask the user to enter words found in the dice tray. When the user enters ZZ (or zZ or Zz), show the following information:
User-defined functions/methods must be used in the program. Do not use break or continue statements. Use any data structure of your choice. Recursion must be used for full credit. Refer to the sample output below.
Sample Run:
Generated Board:
H A H I
V W O S
E E S E
T I P W
Enter words or ZZ to quit:
tip tips sPIt SeE how show notInTheBoard
tie tee tees shows spite
have have have
shave shaves
Aardvark ZymUrgy zZ
You found these words correctly: 14
tees shaves how tie have tee spite show tip shows
see shave spit tips
Words you tried that were incorrect: 3
notintheboard aardvark zymurgy
Number of words the computer found that you could have listed: 66
awe awes epee eve eves ewe ewes hah haves haw
haws his hiss hoe hoes hos hose hoses hows ohs
owe owes pee peso pesos pet pew pews pie pies
pis pit psi set sew sews shah shoe shoes sieve
sip sit site sos sow sows spew ssh sweep sweet
ties tis veep veeps vet wave waves wee weep weeps
wet who whoa whose woe woes
Play again? N