A word search puzzle consists of letters arranged in a grid, some of which form words. The player solves the puzzle by finding all these (hidden) words which can be displayed in any direction. An example of a wordsearch is shown below.

Figure: see image.

For this ACW the student must write a C# console application that implements a word search. The steps that follow form a specification of how the program should function and its features. Where the specification is vague the student can make assumptions, however, the program should not have any features additional to what is described in this specification. All assumption should be clarified with a member of the module staff.

1. Building a Wordsearch

B should be presented with a menu with options to either use a default puzzle file, load the current saved wordsearch or select from a list of files.

Figure: see image.

2. Using the default puzzle file

If the user selects the first option from the initial menu they should be presented with a default wordsearch that is the same as is found in "File01.wrd" but is hard coded into the application. This will ensure students are still able to make progress if they struggle to load wordsearch puzzles from files.

Figure: see image.

3. Selecting from a list of files

If a user selects the second option the program should display all files in the current directory with the file extension ".wrd".

Figure: see image.

Note - this means that your program should look in the current directory to see what file are in the current directory, and ask the user to pick from them.

The following code can be used to return an array of strings with the appropriate file paths:

string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.wrd");

The solution that you have been provided with includes seven wordsearch files. Be aware that some are provided as test files that your program should reject for various reasons - being in the wrong format for example. The program should be able to load any file that is in the correct format. If the program attempts to load a file in the incorrect format it should display an error message and give the user the option to load another file or use the default file. Details of the file format can be found later in this document in the section on "Puzzle File Specification".

Some example test files have been provided for you. You may wish to add additional test cases to your solution. Details of the provided test files are in the table below.

Filename Comments
File01.wrd contains only horizontal words
File02.wrd contains only horizontal and vertical words
File03.wrd contains horizontal, vertical and diagonal words
File04.wrd Incorrect number of words
File05.wrd Incorrect File Format
File06.wrd Words outside of grid
File07.wrd Incorrect overlapping words

As a file is parsed the word search data should be generated and stored in variables. The program should make use of appropriate data structures such as arrays and structs to store the word search

Puzzle File Specification

The word search puzzles are defined in a file that is loaded and parsed by the program. The file uses a comma-separate variable (CSV) format.

The first line of the file specifies:

  • < Number of Columns >, < Number of Rows >, < Total Number of hidden words >
  • Each line that follows specifies the word and its properties:
  • < Word >, < Column Co-ordinate of first letter >, < Row Co-ordinate first letter >, < Direction >
  • Here is an example of a puzzle file;
6,5,3
apple,0,0,right
pear,1,0,down
orange,0,3,right
  • 6x5 puzzle grid with a total of 3 hidden words
  • Word 'apple' starts at cell (0,0) and reads in the right-ward direction
  • Word 'pear' starts at cell (1,0) and reads in the down-ward direction
  • Word 'orange' starts at cell (0,3) and reads in the right-ward direction
  • Here is a graphical representation of what the file specifies;
  • Note that the origin (0,0) is at the top-left cell

4. Loading a Partially Complete Wordsearch

  • If the user chooses to Resume Wordsearch the program should attempt to load the file "wordsearch.sav"
  • The format of the file is undefined, but should encapsulate all the state of the wordsearch such that a user could continue their wordsearch from the point when the program was saved

5. Display the word search board and list the hidden words

  • The puzzle board should have the correct dimensions as specified in the puzzle file
  • The perimeter axis should be labelled and highlighted Yellow
  • The hidden words are displayed on the board. The remainder of the board is filled with random letters
  • The program must also display, beneath the board, a list of the hidden words that have yet to be found

6. Prompt user for input

  • The user should be asked to either identify a word or save and quit.
  • The program must prompt the user to identify a word by inputting 2 co-ordinates, one for the first letter and one for the last letter
  • In the current example the word 'apple' can be identified by the co-ordinates (0,3) for the first letter and (4,3) for the last letter.
  • Note that the order is matters i.e. inputting (4,3) for the first letter and (0,3) for the last letter is incorrect as it spells 'elppa'
  • The user input should be validated and if incorrect the program should handle it (i.e. not crash) and prompt the user of their mistake.

7. Process input

  • The program should process the user's input and detect if a word is found.
  • The program data should be updated to reflect that a word has been found
  • The program should give the user the option to save their progress and quit

8. Saving Progress

  • If the user chooses to save their progress you should save the to a file called "wordsearch.sav". Only one ongoing wordsearch needs to be saved as a time
  • The format of the file is undefined, but should encapsulate all the state of the wordsearch such that a user could continue their wordsearch from the point when the program was saved
  • After saving the program should close

9. Repeat steps 5-7 until all words have been found

  • The program should detect when there are no more words to be found
  • Display a message congratulating the user
  • The user should be given the option to load a new wordsearch or quit the program

Figure: see image.

Program Enhancement - Colour Highlighting

When displaying the puzzle board all the words that have been found should be coloured Green

If the user's makes an incorrect selection it should be coloured Red. Only the previous incorrect selection is highlighted i.e. the red highlighting does not accumulate as the user makes more incorrect selections

Figure: see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.