The goal of this program is to find words hidden in a table of characters. Words can be in the table horizontally, vertically, diagonally and, in all cases, in reverse. To be valid the word must exist in dictionary.txt. Your program must list multiple occurrences of a word.

Your program needs to implement a C++ class which allows the supplied main program to execute and produce results the same as those shown below.

The main program is:

int main(int argc, char * argv[])
{auto start = clock();
Game game(argc, argv);
cout << game << endl;
vector words = game.found();
for (auto l : words)
cout << l << endl;
cout << "Found " << words.size() << " words" << endl;
auto cpu_time = clock() - start;
cout << "Cpu time = " << double(cpu_time) / CLOCKS_PER_SEC << endl;
Game game1(game);
Game game2 = game1;
if (game1 != game)
cout << "Error in game copy 1" << endl;
if (game2 != game)
cout << "Error in game copy 2" << endl;
cout << "Games same " << (game2 == game1) << endl;
return 0;
}

The game can be run in four ways:

1. ./a.out 20 => generate a 20 x 20 table of random lower-case letters and find all words in it.

2. ./a.out 40 8 => generate a 40 x 40 table of random lower-case letters and find all words of length 8 in it.

3. ./a.out puzzle.txt => load the table of characters from puzzle.txt and find all words in it.

4. ./a.out puzzle.txt 6 => load the table of characters from puzzle.txt and find all words of length 6 in it.

Sample output for the supplied file puzzle_maths.txt is:

1. ./a.out puzzle_maths.txt 7 gives:

1 ccompileltga
2 ooutputancnv
3 mussalcidoia
4 pintmirmlnvj
5 unetgpeeodln
6 tpooiloeoiof
7 auliblilptso
8 ttootpdisier
9 ioraaaehtoqe
10 opemanrwanur
11 nohtypqeraer
12 amicrobitlno
13 lthinkingicr
14 votvariableo
compile @(1, 2), Direction is Horizontal
logical @(7, 3), Direction is Reverse Left Diagonal
problem @(10, 2), Direction is Reverse Left Diagonal
solving @(7, 11), Direction is Reverse Vertical
Found 4 words
Cpu time = 0.081756
Games same true

2. ./a.out puzzle_maths.txt 5 gives:

1 ccompileltga
2 ooutputancnv
3 mussalcidoia
4 pintmirmlnvj
5 unetgpeeodln
6 tpooiloeoiof
7 auliblilptso
8 ttootpdisier
9 ioraaaehtoqe
10 opemanrwanur
11 nohtypqeraer
12 amicrobitlno
13 lthinkingicr
14 votvariableo
alcid @(3, 5), Direction is Horizontal
anole @(1, 12), Direction is Left Diagonal
class @(3, 7), Direction is Reverse Horizontal
error @(9, 12), Direction is Vertical
input @(4, 2), Direction is Vertical
iodic @(3, 11), Direction is Reverse Horizontal
logic @(7, 3), Direction is Reverse Left Diagonal
loops @(4, 9), Direction is Vertical
micro @(12, 2), Direction is Horizontal
print @(5, 6), Direction is Reverse Left Diagonal
ratio @(10, 7), Direction is Reverse Right Diagonal
retie @(10, 7), Direction is Right Diagonal
roble @(9, 3), Direction is Reverse Left Diagonal
spool @(8, 9), Direction is Reverse Vertical
start @(8, 9), Direction is Vertical
think @(13, 2), Direction is Horizontal
until @(3, 2), Direction is Right Diagonal
varia @(14, 4), Direction is Horizontal
while @(10, 8), Direction is Reverse Vertical
Found 19 words
Cpu time = 0.047443
Games same true

3. ./a.out 6 puzzle_maths.txt gives:

Invalid input, options are:
< game size >
< game size > < word size >
< file name >
< file name > < word size >
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.