C++ Given Code #include #include #include using namespace std; // The puzzle will always have exactly 20 columns const int numCols = 20; // Searches the entire puzzle, but may use helper functions to implement logic void searchPuzzle(const char puzzle[][numCols], const string wordBank[], vector &discovered, int numRows, int numWords); // Printer function that outputs a vector void printVector(const vector &v); // Example of one potential helper function. // bool searchPuzzleToTheRight(const char puzzle[][numCols], const string &word, // int rowStart, int colStart) int main() { int numRows, numWords; // grab the array row dimension and amount of words cin >> numRows >> numWords; // declare a 2D array char puzzle[numRows][numCols]; // TODO: fill the 2D array via input // read the puzzle in from the input file using cin // create a 1D array for wods string wordBank[numWords]; // TODO: fill the wordBank through input using cin // set up discovery vector vector discovered; // Search for Words searchPuzzle(puzzle, wordBank, discovered, numRows, numWords); // Sort the results sort(discovered.begin(), discovered.end()); // Print vector of discovered words printVector(discovered); return 0; } // TODO: implement searchPuzzle and any helper functions you want void searchPuzzle(const char puzzle[][numCols], const string wordBank[], vector &discovered, int numRows, int numWords) { } // TODO: implement printVector void printVector(const vector &v) { }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C++ Given Code

#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

// The puzzle will always have exactly 20 columns
const int numCols = 20;

// Searches the entire puzzle, but may use helper functions to implement logic
void searchPuzzle(const char puzzle[][numCols], const string wordBank[],
vector <string> &discovered, int numRows, int numWords);

// Printer function that outputs a vector
void printVector(const vector <string> &v);

// Example of one potential helper function.
// bool searchPuzzleToTheRight(const char puzzle[][numCols], const string &word,
// int rowStart, int colStart)


int main()
{
int numRows, numWords;

// grab the array row dimension and amount of words
cin >> numRows >> numWords;

// declare a 2D array
char puzzle[numRows][numCols];

// TODO: fill the 2D array via input
// read the puzzle in from the input file using cin

// create a 1D array for wods
string wordBank[numWords];

// TODO: fill the wordBank through input using cin


// set up discovery vector
vector <string> discovered;

// Search for Words
searchPuzzle(puzzle, wordBank, discovered, numRows, numWords);

// Sort the results
sort(discovered.begin(), discovered.end());

// Print vector of discovered words
printVector(discovered);

return 0;
}

// TODO: implement searchPuzzle and any helper functions you want
void searchPuzzle(const char puzzle[][numCols], const string wordBank[],
vector <string> &discovered, int numRows, int numWords)
{

}

// TODO: implement printVector
void printVector(const vector <string> &v)
{

}

Word Search
A word search is often a rectangular puzzle containing a bunch of characters, when these characters are combined across rows, columns,
or diagonals then hidden words can be discovered.
Assignment Specifications
You will implement a console version of a word search puzzle solver. For this assignment, we are providing an initial source code file which
contains skeleton code that you must complete. You are not allowed to change the provided code. You must use a two-dimensional array
to store the puzzle. Grab the initial C++ file and example input file, then upload all the files to your workspace or place all of the files in the
same folder on your computer if developing locally.
For the functions you must implement, we have provided only a stub. A stub is a function definition that compiles, but does not yet
implement the complete specifications for that function. As you develop the program, you should implement each function one at a time
and test each as you go. Additionally, we encourage the development of several helper functions. These helper functions will benefit your
code organization and will more than likely help reduce the debugging time spent fixing errors in your code.
Helpful Hints
• Solve on paper first!
o record the actual steps you take to find a word
• Go through the given code first and note all the TODO comments
• Don't bite off too much, do one TODO at a time, or even break down a TODO into many steps!
• Don't implement everything at once. A search in all 8 potential directions can be confusing, try implementing search in one direction
then move on to another direction.
o If you solved on paper first, then you should know all the words and the direction for each of the discovered words.
• Print the puzzle and other arrays out to make sure you read it in correctly.
• You should be adding the words to the discovery vector as you find them.
• You only need to find a word once, so it should only exist in the discovery vector a single time.
• Use input redirection to test: /a.out < mylnputFile.txt
o You do not want to type those entire puzzles in!
• The input file and executable must be in the same directory to use the above input redirection.
• Don't wait until the last minute, zyBooks will provide a grade and limited feedback so that you can fix your problems and resubmit
prior to the deadline to earn a better grade!
Example Execution
$ ./a.out < exampleInput.txt
HELLO
Example Input File
3
2
HELLOJKLI Y Q S R P Z IM KOE
W RL DQ JKL IY QS R P Z I M KOF
BY Z ANTINE Q WERTY U IOP z
HELLO
WORLD
Transcribed Image Text:Word Search A word search is often a rectangular puzzle containing a bunch of characters, when these characters are combined across rows, columns, or diagonals then hidden words can be discovered. Assignment Specifications You will implement a console version of a word search puzzle solver. For this assignment, we are providing an initial source code file which contains skeleton code that you must complete. You are not allowed to change the provided code. You must use a two-dimensional array to store the puzzle. Grab the initial C++ file and example input file, then upload all the files to your workspace or place all of the files in the same folder on your computer if developing locally. For the functions you must implement, we have provided only a stub. A stub is a function definition that compiles, but does not yet implement the complete specifications for that function. As you develop the program, you should implement each function one at a time and test each as you go. Additionally, we encourage the development of several helper functions. These helper functions will benefit your code organization and will more than likely help reduce the debugging time spent fixing errors in your code. Helpful Hints • Solve on paper first! o record the actual steps you take to find a word • Go through the given code first and note all the TODO comments • Don't bite off too much, do one TODO at a time, or even break down a TODO into many steps! • Don't implement everything at once. A search in all 8 potential directions can be confusing, try implementing search in one direction then move on to another direction. o If you solved on paper first, then you should know all the words and the direction for each of the discovered words. • Print the puzzle and other arrays out to make sure you read it in correctly. • You should be adding the words to the discovery vector as you find them. • You only need to find a word once, so it should only exist in the discovery vector a single time. • Use input redirection to test: /a.out < mylnputFile.txt o You do not want to type those entire puzzles in! • The input file and executable must be in the same directory to use the above input redirection. • Don't wait until the last minute, zyBooks will provide a grade and limited feedback so that you can fix your problems and resubmit prior to the deadline to earn a better grade! Example Execution $ ./a.out < exampleInput.txt HELLO Example Input File 3 2 HELLOJKLI Y Q S R P Z IM KOE W RL DQ JKL IY QS R P Z I M KOF BY Z ANTINE Q WERTY U IOP z HELLO WORLD
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Map
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education