Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this game, given a matrix of letters and a list of words, goal is to find all the words - they may appear as

In this game, given a matrix of letters and a list of words, goal is to find all the words - they may appear as a sequence of characters in any stright line: Left-to-Right, Right-to-Left, Top-to-Down, Down-to-Top, Right-Diagonal-Down, Right-Diagonal-Up, Left-Diagonal-Down, Left-Diagonal-Up. Now, instead of asking the humans to find the words, we will write a program to do it!

Given code:

#include

#include

#include

using namespace std;

char matrix[100][100];

int matrixSize = 0;

bool display[100][100];

string *words;

int numWords = 0;

// WRITE YOUR CODE HERE

int main() {

string filename;

cin >> filename;

ifstream finput(filename);

finput >> matrixSize;

for(int i=0 ; i

for(int j=0 ; j

finput >> matrix[i][j];

cout << matrix[i][j] << " ";

display[i][j] = false;

}

cout << endl;

}

finput >> numWords;

words = new string [numWords];

for(int i=0 ; i

finput >> words[i];

cout << words[i] << endl;

findWord(words[i]);

}

for(int i=0 ; i

for(int j=0 ; j

cout << (display[i][j] ? matrix[i][j] : ' ') << " ";

cout << endl;

}

}

PuzzleMaker is one such site to create such puzzles. Here is a sample input file content. You can assume that we will not go above 20x30 matrix and max 20 input words as well.

15 R R H O E A Y Y N S W L Z W L F E K Q R F Q D N N P V Y U Y T G M R C S U O I O F O L Q Z E C A M G R I U H I P C O I K I Y W H A T Y V L S Q A L L H S F H A C R L F A I S C D J I V S T N W K G Z L C N I J S N A R U E S R U O C E N G J O M I F P E K E X H R D E O H F U B T H T P E Q A Y P E L K T T R O N S C P L U S P L U S W G W Y V X Z I P H E Y I E Y A X Z W E U B P B A W N A X P R Z K T H R H D D J Z I C H C E J L Z T H I V C S Z I H E K C N 10 ARRAYS COURSE CPLUSPLUS DECISIONS FUNCTIONS LOGIC LOOPS PROGRAMMER SEQUENCE SOFTWARE 

Here is the corresponding output:

R A S E R N N P M R O O O A M I I O Y A T S L S C R I C N G C I S U E S R U O C E G O F E R D O F Q P L T C P L U S P L U S W E A N R C E E

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions

Question

Were they made on a timely basis?

Answered: 1 week ago

Question

Did the decisions need to be made, or had they already been made?

Answered: 1 week ago

Question

When there was controversy, was it clear who had the final say?

Answered: 1 week ago