600.120 Intermediate Programming
Spring 2010 -- Assignment 3
Due Thursday 2/25 by 2:45pm
60 points total

The goal for this week is to do even more structured programming in C, using structs, functions and header files to organize processing. You will really need pointers to update data (function parameters) this time.

The Problem: Word Search

Write a program to solve a word search puzzle. The initial input to the program should be the dimensions of the grid (rows and columns) on the first line of input, followed by the actual grid of characters. The input may contain upper and lower case characters, but you should convert them all to lower case when you read them.

Your program should repeatedly display the grid on the screen, and then prompt the user for a word to find. For each word (until the user is done), the program should search the grid for the word. It is up to you to decide how the user will indicate they are done. If it is by entering an end of input (EOF) marker, remember to type a ^d in unix when testing from the keyboard.

A word could appear in the grid forwards or backwards, horizontally, vertically or diagonally (either direction), with the characters in the proper order in adjacent cells. Also remember that different words might share characters. Search for the word in all directions if necessary (8 total including the reverse of the word) and say whether or not it was found. In order to indicate where a word was found, change its characters to upper case in the grid. This change should persist through future word search iterations. Finding and changing the word to uppercase is one place where you need to think hard about efficiency issues.

Since we haven't worked with files yet, write your program to read from standard input. This will be useful for conducting very small unit tests to search for words in each of the 8 possible directions. Don't forget to test boundary cases thoroughly. When you are ready for a larger test, set up a plain text file with all the input as if you would have typed it in when running the program. Use unix input redirection to make your program read from this file instead of the keyboard. You should download my file with sample input and edit it to match your program input requirements (when getting the words to search for) for testing. You must also create your own file with a reasonably large example (at least 20x20) that contains a complete set of words to search for, covering every possible case. You must submit both of these files along with your program solution.

Implementation Details:

Submission: This week you are required to use tar and gzip (or tar with the z option) to collect all the files you are submitting into one compressed file. This includes all *.h files, *.c files, two sample input files (*.txt), and your makefile. Upload and submit that one p3.tar.gz file onto webCT. If you need to retrieve and resubmit, make sure that you again tar and gzip all your files together. If you need to explain anything in general, include a README plain text file with your submission. Anything not on webCT by the deadline gets a 0 = no credit. Also bring a printout of all your source code (*.h and *.c files) to class on the due date. Make sure that every source file has a header comment with your name, email and webCT login. Please staple together all the pages for each file and submission.

Grading: Make your code as efficient as possible, both in terms of space and time!! This means avoiding unnecessary copying of data. You should const protect data whenever possible. -5 points if there are any warnings using the required compilation options. 0 points if it doesn't compile (has errors, no a.out created). Any violation of the STRICT implementation details (above) will result in a 0 grade for the assignment. This is a perfect time to practice incremental coding development!!