Please read the remarks about programming problems for this course.


Task

A word search puzzle consists of words hidden in a rectangular block of random characters. You will complete a C++ program that reads in a list of words to find and a word search puzzle. Your program then will print the solution to the puzzle.

In class we considered two possible strategies for finding hidden words within a word search puzzle. In this assignment you will select and implement a strategy to solve a word search puzzle.

Organization

The word search program you are to complete consists of five C++ files, found here:

These files constitute a C++ project that will build and run. You modify only the wordsearch.cpp file. Do not modify any of the other files; your code must compile and run successfully within the context of the other existing files.

You should study all the code provided, especially the code that reads data from a text file and the overloaded operator functions. You may need to write similar code yourself in the future.

Details

The program within wspuzzle.cpp reads the list of words from a text file named wordlist.txt. The file should contain ten words, each on its own line. No word will contain more than 15 letters. The program then reads from puzzle1.puz a 20 x 20 word search puzzle with the words from the word list hidden inside.

Your program's behavior is undefined if the puzzle has no solution; this means you need not worry about this possibility.

Output

The program produces the following output, in the following order:

  1. the list of words to find,
  2. the puzzle, and
  3. the answer key.

    Here is the output of a sample run.

    COMPUTER ALGORITHM WHILE PROGRAM COMPILER PROCESSOR MEMORY ITERATIVE RECURSIVE CONDITIONAL P M N R B L H R K X R J F T K B P F W C I E X L B U M W E P U V M U Q R N L T B B P M R K L P E C C N T M D O D F Q W G X K T H A F X B O X U T M G H K S E B E C E Z X Y M B R M M G R R L L K M K Y T O R Z Z Q D L E P G H A S R F W R P K E Z D X R T F Y L U V M I G I P E T O W Z O O W E D O B I T J X M N A V J S D W C X U R R Y X T H E L E P H M Z E W B S N A N G R U P C W R R X P L T E V R Y I E Z W L U Y I M P E E R M B E I U A H P X I I M E M O R Y B L L Y T X J R T R T U U E G L D O O E Y I D G C J H G O D J X G C D B U R K J Q P A E Y C P C V G R F Q B X H X E V H U M J G V W E R M R L T Q S R P L X Z L H O L K Y S M D P S Y A E V C O Y B O J M C H K S F E X A S L E Z N E M J O G W F Q N O V U X I L Z D M E V I T A R E T I W R K N H D V X X A I Z G S L S M L A N O I T I D N O C T Z F R P E R C C O O U G M R R E P A S L U M I I T M V H E H E W R R T E I P M E M O R Y L R R I O P C G M E L O S A C S O E V I T A R E T I R L A N O I T I D N O C

    It is possible that for some puzzles your program generates a correct key that is different from the correct key that someone else's program generates for that same puzzle. This especially is true if the hidden words are short. This is because a word in the list may be coincidentally duplicated in other locations within the puzzle. A proper puzzle would have only one solution. Since your program has no control over the puzzle, as long as your program produces a correct solution, your program is considered correct. You need not worry about handling multiple answers in ambiguous puzzles.

    Strategy

    You have only one required function to write, but there is a lot of other code involved that you need to understand. You have one and one-half weeks to complete the assignment, but most students will want to set aside a few hours over several days to complete the assignment. The following represents a reasonable time schedule for this assignment:

    1. Read and re-read this assignment carefully and completely. (0.5 hour)

    2. Install, if necessary, the C++ IDE or build system of your choice. (0.5 hour)

    3. Collect all the code into a project within the C++ IDE or build system of your choice. Before you begin to implement the solve function ensure that you can compile and run the code provided. (0.5 hour)

    4. Study carefully the code provided. Be sure you understand the purpose of all the parts. (2 hours)

    5. Think about the problem and devise a solution. (Several hours, possibly spread out over several days)

    6. Implement and test your solution in C++. (Several hours, possibly spread out over several days as you reacquaint yourself with C++)

    Submission

    Submit your completed wordsearch.cpp C++ source file to http://eclass.e.southern.edu. Be sure your name appears within a comment as the first line in each source file you submit.