|
CMSC 201 Recursive Word Search Out: Sunday 11/13/05 The design document for this project, design4.txt, is due: Before Midnight, Sunday 11/20/04 |
A word search is a 2-dimensional grid or matrix of letters which contains "hidden words". The person working the puzzle is given a list of words that are hidden in the matrix and is asked to locate and circle them. The fun part is that the words may appear horizontally, vertically or diagonally in the grid. Horizontal words may be written left-to-right or right-to-left. Vertically oriented words may be written top-down or bottom-up. Similarly for diagonally oriented words.
Here's a simple word search puzzle for you:
It is not the same size as the ones your program has to handle.
This one is 12 X 12, not 15 X 15.
G J T P B A V K U V L V
M N Q H S G M N T C E E
Y H I J S G Q E N Y C W
G S K M G H C B M U T H
R A T V M N V D G V U T
E P G U E A B P W Q R T
T J C I D D R Q T E E C
U P C I S E N G B U O B
P S J C I V N F O U N N
M P R O J E C T R R A M
O H Q T P P D S H A P G
C O W U K Q E G I J M S
COMPUTER
COURSE
LECTURE
PROGRAMMING
PROJECT
SCIENCE
STUDENT
UMBC
You are to read in the puzzle from one file and the words to search for from
another file. Your program must then search for each of the words in the
letters grid recursively. When the word is found, the position of its first
character (row and column) must be stored and also that word's orientation
from its starting position (direction).
For example in the grid shown above:
COMPUTER begins at Row 12, Column 1 and its direction is Up
PROJECT begins at Row 10, Column 2 and its direction is Right
UMBC begins at Row 4, Column 10 and its direction is Left
typedef struct word
{
char word[16]; /* You should use a #defined constant for this size */
int startRow;
int startCol;
char direction;
}WORD;
The executable and the data files need to be in the same directory when you
run the program. The commands to copy the files are:
cp /afs/umbc.edu/users/s/b/sbogar1/pub/letters.dat .
cp /afs/umbc.edu/users/s/b/sbogar1/pub/words.dat .
[wordsearch]% a.out letters.dat words.dat answers.out
Your greeting goes here
EHUKXDICNMYTYLF
WOCJSKLTIMHONII
NOTGNIHSAWZIFNP
IRBWNIIWPPIERCE
BMETVELIIOKOWOK
QUOWCLEVELANDLN
VNCCOORTHTSNUNA
AMKHRHFELSIONOM
DULNAANETXUQNSU
AIOATNVEORKBARR
MMPZVEANSUALBET
SYSDSWGNBITCLFI
OHZOMYDENNEKWFD
IAOTNARGRNVTFEF
KRRVFVEEDMBDMJZ
ADAMS
CLEVELAND
GRANT
JEFFERSON
KENNEDY
LINCOLN
NEMO
PIERCE
POLK
TRUMAN
WALDO
WASHINGTON
[wordsearch]% cat answers.out
Word Row Col Direction
------------------------------------------
ADAMS 8 1 Down
CLEVELAND 6 5 Right
GRANT 14 8 Left
JEFFERSON 15 14 Up
KENNEDY 13 12 Left
LINCOLN 1 14 Down
NEMO 0 0 Not Present
PIERCE 4 10 Right
POLK 11 3 Up
TRUMAN 11 15 Up
WALDO 0 0 Not Present
WASHINGTON 3 10 Left
[wordsearch]%
Please note that the sample output only shows what is expected from your
program if the user is actually entering everything as instructed. This
is not a test of the program at all, but just a sample for your
clarification.
To submit your program, type the following command at the Unix prompt
submit cs201 Proj4 proj4.c followed by all the .c and .h files necessary for compilation
To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.
submitls cs201 Proj4