6.25 LAB: Word Search
initial c++ file/starter code:
#include <vector>#include <iostream>#include <algorithm>
using namespace std;
// The puzzle will always have exactly 20 columnsconst int numCols = 20;
// Searches the entire puzzle, but may use helper functions toimplement logicvoid searchPuzzle(const char puzzle[][numCols], const stringwordBank[],vector <string> &discovered, int numRows, intnumWords);
// Printer function that outputs a vectorvoid printVector(const vector <string> &v);// Example of one potential helper function.// bool searchPuzzleToTheRight(const char puzzle[][numCols], conststring &word,// int rowStart, int colStart)
int main(){int numRows, numWords;
// grab the array row dimension and amount of wordscin >> numRows >> numWords;// declare a 2D arraychar 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 wodsstring wordBank[numWords];// TODO: fill the wordBank through input using cin
// set up discovery vectorvector <string> discovered;
// Search for WordssearchPuzzle(puzzle, wordBank, discovered, numRows, numWords);
// Sort the resultssort(discovered.begin(), discovered.end());
// Print vector of discovered wordsprintVector(discovered);
return 0;}
// TODO: implement searchPuzzle and any helper functions youwantvoid searchPuzzle(const char puzzle[][numCols], const stringwordBank[],vector <string> &discovered, int numRows, intnumWords){}
// TODO: implement printVectorvoid printVector(const vector <string> &v){}example input file:
32
H E L L O J K L I Y Q S R P Z I M K O PW R L D Q J K L I Y Q S R P Z I M K O PB Y Z A N T I N E Q W E R T Y U I O P Z
HELLOWORLDstar wars file:
2515L P O A G Y R K T A T O O I N E D O X LJ G G T J U V R E B A S T H G I L J Y NF P A X B E L L D N Y U E Z B I E S N HL E I A H K S U S S A M C V B H N T W SU I Z U L F F K D O T E J O Z F M D T ZB M G L G Z E E H R N I N C W X X O T RI S N T X T K S Z T O E R E H U R D I IM V P N B W A H L A K I W K X M R C F JP Z H K L Z J T G T P N D P T P V X Y HU N W W J Y J R L W U I O R R Y O X P PG A A I L I B A D V S Y O I U Q H O D FM O D W Z Z Q D K N Q O N A N F P T H RD V Z G Y W Z Y Q P P C H G V M T J P PL Q H V E Z V T G E E M O O F S L G Y LC Z L U P S A M R S G V X V M I L T F RU A K B O Z R T S T C Z T P D T A X K AU A W A V V X I E I D L C Y O O B C N NS Y I W X C N D V N C H H C D R J A Y AG J E D I I E Q N S S N G H O I E W I KG F E G H R J E G L L P Q O Y Q O D E IA V V N N P D T W R D V C M A G S J A NA D N I Q Y Y G O W Y E D Y Z A O O P VR J O K N J M Z L V T U V W H F O F D VV C T Z H U O B I W A N Z H I P Y B Z ML M X Y N I T G C Q E L V U Q B P L D L
AMIDALA ANAKIN DARTHDROID JEDI KENOBILEIA LIGHTSABER LUKEOBIWAN PRINCESS STORMTROOPERTATOOINE TWILEK VADERtoy story file:
1738
S T I N K Y P E T E Y O C K D Y N E Y CB B Y A J S S D R Y M B B H S Q Y R N FW J S D L J U F P A L O O T U E V R N UK T B I O C P H Z D O L R P S C E T E EE I N H K O R F J K H E O L E X K P L RB K A Y D Z W A W U T S L M B E T L E KY Q C D B K Z O E C U U H A E F P T E RB O Y D N A R U H Y B A R E A S S D H ST I J A A M E O B N T B I L R U H U T PQ L G V S I P T P L I H I Y B I B H Q UE E I B X A B A M E H E G S S Z F D D CH M I I A I R T H T N T H I G U E F O RQ D R S X B I O E S L O S A L R A F L EI T J M S H Y P G Q O C N D B G E O L TR P N I U E W W R F T N H A M M E Y Y TE E M I L Y J J A N S H N E K E N K M UG Y Z E E H W M S A O F H C T I W T P B
ALIENSANDYBARBIEBIGBABYBOOKWORMBOPEEPBULLSEYEBUSTERBUTTERCUPBUZZCHUCKLESDAISYDAPHNEDOLLYDUCKYEMILYGERIHAMMJESSIEKENLENNYLIGHTYEARLOTSOMOLLYPOTATOREXRIPSARGESHERIFFSLINKYSTINKYPETESTRETCHTRIXIETWITCHWARDOGWHEEZYWOODYZURG
c++ code
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. 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, hen you should know all • 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 • 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. words and the direction for each of disc ered words. • 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!
6.25 LAB: Word Search initial c++ file/starter code: #include #include #include using na
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am