Question

In: Computer Science

Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The...

Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The words that need to be found are in the file 'WordList.txt'.

There are 100 words to be found. You must find the location of the first and last letter of each word as well as the cardinal direction that describes the word's orientation. The location of first and last letters are to be described in terms of row and column, with indexing starting at 0 and originating from the top left corner. See below for an example.

Example:

A Y U O E R
X D K N W N
G Q O T J S
H B I V M C

For the word 'BONE', the first letter, 'B', is in row 3, column 1; the last letter, 'E', is in row 0, column 4. The word is orientated in an ascending diagonal direction such that it is read starting at the bottom left and finishing at the top right; this word is said to be 'headed' in a 'North East' (NE) direction.

Directions:

North West(NW)
North (N)
North East (NE)
East (E)
South East (SE)
South (S)
South West (SW)
West (W)
You must print each found word in a new file (all results in same file, new line for each result). For the example above, below is the output that should be written to the results file:

BONE found @ (3, 1) - (0, 4) : NE

Note the capitalization of the word and cardinal direction, and the spacing between the rest of the words and other characters.

Requirements:

Create a set of functions and structures that solve the puzzle
Write results to a file

WordSearchPuzzle.txt

REKMASRQHFOLOEEIBMOZZQKOHNTLBSCFINILYGRHCZNXTIOYKT
BDSIUACWAWHCLENIIXQNFTPTIHGCLISKUROJODIVERXRVOHIOG
AFIEBMYUXZTDOOSOERRLCVOLOULCEXLHJEIKANXXLMNIOPBMHQ
LXLUIDMHAOKLDDRMBLTRBMBKAUGJSWODTTEQYGIAHUJVPCBOFU
YXIKRRQYBYAWIHDOOPYBEOTZNJGIZZXIRNIWNNXIATIUPSILRR
DBSWQAFEHEXULTEANKXHGCNHCLTIRKEOXACCDYLADSVSTTENBK
MAATEYRTVTZFAANZSAEGOYTLGWAMPUSUJLZHGORELTIOTFDGUI
YTBBBERKCFKSARIUMBWFMJAANIANNODLEOIAFUMQXKNVCYBWJM
VNNXDVAARIMQAADCOZFPXRCEBHNGACKYAKDNTWEYQERNQILGBV
ZJLMPADTYGAEPNRETIHRTCEOLURDLPMFACMJEKXJJUBNJTQVSA
YPR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RA
COBWEB
COFFIN
CORPSE
CRONENBERG
CRYPT
CTHULHU
DARK
DARKNESS
DEATH
DEMENTOR
DEMON
DEVIL
DUNGEON
EERIE
ELDONNA
ELF
FENRIR
FRIGHT
GHOST
GHOUL
GOBLIN
GORE
GRAVEYARD
HALLOWEEN
HAUNTED
HOMUNCULUS
HYOSUBE
IMP
JACKALOPE
JACKOLANTERN
JINN
KRAKEN
KRAMPUS
KRUEGER
LAMIA
LILIN
LLORONA
LYCAN
MACABRE
MARA
MEDUSA
MIDNIGHT
MORBID
MUMMY
NIGHT
NIGHTMARE
NYMPH
OCTOBER
OGRE
PHANTASM
PHANTOM
POLTERGEIST
PUCKWUDGIE
QAREEN
REAPER
RIP
ROACH
ROBOT
SCREAM
SKULL
SLENDERMAN
SPELL
SPIDER
SPOOKY
TARANTULA
THESTRAL
TOMBSTONE
TREAT
TRICK
TROLL
UNICORN
VAMPIRE
WAMPUS
WARLOCK
WENDIGO
WEREWOLVE
WHITELADY
WRAITH
WYVERN
XIAO
XINDHI
YOKAI
YUREI
ZOMBIE

Solutions

Expert Solution

//================readFile.h================
/*
* readFile.h
*
* Created on: 31-Oct-2020
* Author: abc
*/

#ifndef READFILE_H_
#define READFILE_H_
#include <stdio.h>
#include <stdlib.h>
//________________________
int readFile(char fileName[],char arr[][51]){
   FILE *fp;
   fp=fopen(fileName,"r");
   if(fp==NULL){
       printf("Unable to open file\n");
       return -1;
   }
   int count=0;
   while(fscanf(fp,"%[^\n]\n ",arr[count])!=EOF){
       count++;
   }
   fclose(fp);
   return count;
}
//_______________________
void printArray(char arr[][51],int size){
   for(int i=0;i<size;i++){
       printf("%s\n",arr[i]);
   }
}
#endif /* READFILE_H_ */
//====end of readFile.h====================

//=====findWord.h=================
/*
* findWord.h
*
* Created on: 31-Oct-2020
* Author: niran
*/

#ifndef FINDWORD_H_
#define FINDWORD_H_
#include<string.h>
#include <stdio.h>
#include <stdlib.h>
#define COL 51
#define ROW 50

//_________________________
int south(char arr[][COL],char word[COL],int row,int col,int *endRow,int *endCol){
   int len=strlen(word);
   int i;
   for(i=0;i<len;i++){
       if(row<ROW){
           if(word[i]!=arr[row][col])
               return 0;
           row++;
       }else{
           break;
       }
   }
   if(i==len){
       *endRow=row-1;
       *endCol=col;
       return 1;
   }
   else
       return 0;
}
//_________________________
int southWest(char arr[][COL],char word[COL],int row,int col,int *endRow,int *endCol){
   int len=strlen(word);
   int i;
   for(i=0;i<len;i++){
       if(row<ROW && col>=0){
           if(word[i]!=arr[row][col])
               return 0;
           row++;
           col--;
       }else{
           break;
       }
   }
   if(i==len){
       *endRow=row-1;
       *endCol=col+1;
       return 1;
   }
   else
       return 0;
}
//__________________________
int southEast(char arr[][COL],char word[COL],int row,int col,int *endRow,int *endCol){
   int len=strlen(word);
   int i;
   for(i=0;i<len;i++){
       if(row<ROW && col<COL-1){
           if(word[i]!=arr[row][col])
               return 0;
           row++;
           col++;
       }else{
           break;
       }
   }
   if(i==len){
       *endRow=row-1;
       *endCol=col-11;
       return 1;
   }
   else
       return 0;
}
//_________________________
int north(char arr[][COL],char word[COL],int row,int col,int *endRow,int *endCol){
   int len=strlen(word);
   int i;
   for(i=0;i<len;i++){
       if(row>=0){
           if(word[i]!=arr[row][col])
               return 0;
           row--;
       }else{
           break;
       }
   }
   if(i==len){
       *endRow=row+1;
       *endCol=col;
       return 1;
   }
   else
       return 0;
}
//_______________________
int northWest(char arr[][COL],char word[COL],int row,int col,int *endRow,int *endCol){
   int len=strlen(word);
   int i;
   for(i=0;i<len;i++){
       if(row>=0 && col>=0){
           if(word[i]!=arr[row][col])
               return 0;
           row--;
           col--;
       }else{
           break;
       }
   }
   if(i==len){
       *endRow=row+1;
       *endCol=col+1;
       return 1;
   }
   else
       return 0;
}
//________________________
int northEast(char arr[][COL],char word[COL],int row,int col,int *endRow,int *endCol){
   int len=strlen(word);
   int i;
   for(i=0;i<len;i++){
       if(row>=0 && col<COL-1){
           if(word[i]!=arr[row][col])
               return 0;
           row--;
           col++;
       }else{
           break;
       }
   }
   if(i==len){
       *endRow=row+1;
       *endCol=col-1;
       return 1;
   }
   else
       return 0;
}
//________________________
int east(char arr[][COL],char word[COL],int row,int col,int *endRow,int *endCol){
   int len=strlen(word);
   int i;
   for(i=0;i<len;i++){
       if(col<COL-1){
           if(word[i]!=arr[row][col])
               return 0;
           col++;
       }else{
           break;
       }
   }
   if(i==len){
       *endRow=row;
       *endCol=col-1;
       return 1;
   }
   else
       return 0;
}
//__________________________
int west(char arr[][COL],char word[COL],int row,int col,int *endRow,int *endCol){
   int len=strlen(word);
   int i;
   for(i=0;i<len;i++){
       if(col>=0){
           if(word[i]!=arr[row][col])
               return 0;
           col--;
       }else{
           break;
       }
   }
   if(i==len){
       *endRow=row;
       *endCol=col+1;
       return 1;
   }
   else
       return 0;
}
//_________________________
void findWord(char puzzle[][COL],char word[COL],FILE *fp){
   int startRow,startCol,endRow,endCol;
   int found=0;
   for(int i=0;i<ROW;i++){
       startRow=i;
       for(int j=0;j<COL-1;j++){
           startCol=j;
           found=south(puzzle,word,i,j,&endRow,&endCol);
           if(found==1){
               printf("%s found @ (%d, %d)-(%d, %d):S\n",word,startRow,startCol,endRow,endCol);
               fprintf(fp,"%s found @ (%d, %d)-(%d, %d):S\n",word,startRow,startCol,endRow,endCol);
           }
           found=north(puzzle,word,i,j,&endRow,&endCol);
           if(found==1){
               printf("%s found @ (%d, %d)-(%d, %d):N\n",word,startRow,startCol,endRow,endCol);
               fprintf(fp,"%s found @ (%d, %d)-(%d, %d):N\n",word,startRow,startCol,endRow,endCol);
           }
           found=east(puzzle,word,i,j,&endRow,&endCol);
           if(found==1){
               printf("%s found @ (%d, %d)-(%d, %d):E\n",word,startRow,startCol,endRow,endCol);
               fprintf(fp,"%s found @ (%d, %d)-(%d, %d):E\n",word,startRow,startCol,endRow,endCol);
           }
           found=west(puzzle,word,i,j,&endRow,&endCol);
           if(found==1){
               printf("%s found @ (%d, %d)-(%d, %d):W\n",word,startRow,startCol,endRow,endCol);
               fprintf(fp,"%s found @ (%d, %d)-(%d, %d):W\n",word,startRow,startCol,endRow,endCol);
           }
           found=northWest(puzzle,word,i,j,&endRow,&endCol);
           if(found==1){
               printf("%s found @ (%d, %d)-(%d, %d):NW\n",word,startRow,startCol,endRow,endCol);
               fprintf(fp,"%s found @ (%d, %d)-(%d, %d):NW\n",word,startRow,startCol,endRow,endCol);
           }
           found=northEast(puzzle,word,i,j,&endRow,&endCol);
           if(found==1){
               printf("%s found @ (%d, %d)-(%d, %d):NE\n",word,startRow,startCol,endRow,endCol);
               fprintf(fp,"%s found @ (%d, %d)-(%d, %d):NE\n",word,startRow,startCol,endRow,endCol);
           }
           found=southWest(puzzle,word,i,j,&endRow,&endCol);
           if(found==1){
               printf("%s found @ (%d, %d)-(%d, %d):SW\n",word,startRow,startCol,endRow,endCol);
               fprintf(fp,"%s found @ (%d, %d)-(%d, %d):SW\n",word,startRow,startCol,endRow,endCol);
           }
           found=southEast(puzzle,word,i,j,&endRow,&endCol);
           if(found==1){
               printf("%s found @ (%d, %d)-(%d, %d):SE\n",word,startRow,startCol,endRow,endCol);
               fprintf(fp,"%s found @ (%d, %d)-(%d, %d):SE\n",word,startRow,startCol,endRow,endCol);
           }
       }
   }
}
#endif /* FINDWORD_H_ */
//==========end of findWord.h==============

//=====testMain.cpp==========================
/*
* testMain.c
*
* Created on: 31-Oct-2020
* Author: abc
*/
#include <stdio.h>
#include "readFile.h"
#include "findWord.h"

int main(){
   char puzzle[50][51];
   char word[150][51];
   int n=readFile("WordSearchPuzzle.txt",puzzle);
   int m=readFile("WordList.txt",word);
   FILE *fp=fopen("result.txt","w");
   if(fp==NULL){
       printf("Unable to open file!\n");
       return 0;
   }
   for(int i=0;i<m;i++){
       findWord(puzzle,word[i],fp);
   }
   fclose(fp);
   return 0;
}
//====end of testMAin.c=======================
//result.txt

ABACUS found @ (42, 10)-(47, 5):SE
ALIEN found @ (12, 39)-(8, 35):NW
BANSHEE found @ (21, 4)-(21, 10):E
BASILISK found @ (7, 2)-(0, 2):N
BAT found @ (5, 1)-(7, 1):S
BAT found @ (8, 24)-(6, 22):NW
BAT found @ (13, 22)-(15, 20):SW
BAT found @ (36, 20)-(38, 20):S
BAT found @ (39, 2)-(37, 2):N
BEAST found @ (36, 20)-(32, 20):N
BEHEMOTH found @ (7, 17)-(0, 24):NE
BLOODYMARY found @ (14, 32)-(14, 41):E
BOGEYMAN found @ (42, 4)-(42, 11):E
BONE found @ (3, 16)-(0, 13):NW
BOO found @ (20, 3)-(18, 3):N
BOO found @ (29, 41)-(31, 41):S
CADAVER found @ (35, 15)-(41, 11):SE
CANDYMAN found @ (42, 0)-(49, -3):SE
CEMETERY found @ (8, 15)-(15, 15):S
CHUD found @ (16, 45)-(13, 45):N
CHUPACABRA found @ (28, 11)-(37, 10):SE
COBWEB found @ (39, 27)-(44, 27):S
COFFIN found @ (5, 21)-(10, 16):SW
CORPSE found @ (45, 9)-(45, 4):W
CRONENBERG found @ (32, 48)-(41, 48):S
CRYPT found @ (27, 43)-(23, 47):NE
CTHULHU found @ (39, 22)-(45, 22):S
DARK found @ (15, 17)-(18, 14):SW
DARK found @ (29, 38)-(26, 41):NE
DARKNESS found @ (15, 17)-(22, 10):SW
DEATH found @ (37, 6)-(37, 10):E
DEMENTOR found @ (30, 47)-(30, 40):W
DEMON found @ (31, 10)-(35, 4):SE
DEVIL found @ (13, 47)-(17, 47):S
DUNGEON found @ (18, 27)-(24, 21):SW
EERIE found @ (14, 4)-(18, 0):SW
ELDONNA found @ (7, 32)-(7, 26):W
ELF found @ (5, 46)-(3, 48):NE
ELF found @ (9, 22)-(11, 14):SE
ELF found @ (12, 20)-(12, 18):W
ELF found @ (14, 22)-(14, 24):E
FENRIR found @ (14, 24)-(9, 19):NW
FRIGHT found @ (16, 25)-(11, 25):N
GHOST found @ (18, 40)-(18, 36):W
GHOUL found @ (30, 49)-(26, 45):NW
GOBLIN found @ (5, 20)-(0, 25):NE
GORE found @ (6, 36)-(6, 39):E
GRAVEYARD found @ (11, 5)-(3, 5):N
HALLOWEEN found @ (15, 16)-(7, 24):NE
HAUNTED found @ (40, 15)-(34, 9):NW
HOMUNCULUS found @ (27, 21)-(36, 12):SW
HYOSUBE found @ (33, 8)-(27, 8):N
IMP found @ (38, 22)-(38, 24):E
JACKALOPE found @ (46, 22)-(46, 30):E
JACKOLANTERN found @ (11, 33)-(0, 33):N
JINN found @ (42, 12)-(45, 5):SE
KRAKEN found @ (46, 31)-(46, 36):E
KRAMPUS found @ (40, 0)-(34, 6):NE
KRUEGER found @ (17, 14)-(17, 20):E
LAMIA found @ (47, 39)-(43, 39):N
LILIN found @ (20, 45)-(16, 49):NE
LLORONA found @ (0, 11)-(6, 7):SE
LYCAN found @ (32, 37)-(32, 41):E
MACABRE found @ (8, 10)-(14, 10):S
MARA found @ (9, 30)-(12, 30):S
MEDUSA found @ (23, 23)-(28, 18):SE
MIDNIGHT found @ (11, 29)-(4, 22):NW
MORBID found @ (16, 31)-(21, 31):S
MUMMY found @ (0, 3)-(4, -3):SE
NIGHT found @ (8, 26)-(4, 22):NW
NIGHT found @ (16, 43)-(20, 43):S
NIGHT found @ (32, 13)-(36, 7):SE
NIGHTMARE found @ (32, 13)-(40, 11):SE
NYMPH found @ (5, 22)-(9, 18):SW
OCTOBER found @ (0, 12)-(6, 6):SW
OGRE found @ (9, 23)-(12, 20):SW
PHANTASM found @ (29, 37)-(22, 37):N
PHANTOM found @ (44, 38)-(44, 32):W
POLTERGEIST found @ (34, 35)-(24, 45):NE
PUCKWUDGIE found @ (21, 37)-(21, 28):W
QAREEN found @ (14, 29)-(19, 24):SW
REAPER found @ (21, 43)-(21, 38):W
RIP found @ (21, 13)-(19, 15):NE
RIP found @ (31, 27)-(33, 27):S
RIP found @ (33, 17)-(35, 9):SE
RIP found @ (40, 26)-(38, 24):NW
ROACH found @ (29, 27)-(29, 23):W
ROBOT found @ (4, 48)-(0, 44):NW
SCREAM found @ (38, 44)-(33, 39):NW
SKULL found @ (26, 49)-(22, 49):N
SLENDERMAN found @ (35, 9)-(26, 0):NW
SPELL found @ (13, 20)-(9, 24):NE
SPIDER found @ (14, 26)-(9, 26):N
SPOOKY found @ (20, 1)-(15, 6):NE
TARANTULA found @ (5, 13)-(13, 13):S
THESTRAL found @ (13, 16)-(6, 23):NE
TOMBSTONE found @ (0, 49)-(8, 41):SW
TREAT found @ (48, 16)-(48, 20):E
TRICK found @ (45, 0)-(49, -6):SE
TROLL found @ (32, 21)-(36, 21):S
UNICORN found @ (6, 48)-(0, 42):NW
VAMPIRE found @ (36, 27)-(30, 27):N
WAMPUS found @ (6, 25)-(6, 30):E
WARLOCK found @ (32, 14)-(26, 20):NE
WENDIGO found @ (22, 38)-(22, 44):E
WEREWOLVE found @ (27, 17)-(27, 9):W
WHITELADY found @ (20, 48)-(12, 40):NW
WRAITH found @ (23, 14)-(28, 9):SE
WYVERN found @ (37, 21)-(42, 21):S
XIAO found @ (40, 44)-(40, 41):W
XINDHI found @ (2, 39)-(7, 34):SW
YOKAI found @ (43, 16)-(47, 12):SW
YUREI found @ (44, 43)-(44, 39):W
ZOMBIE found @ (0, 19)-(0, 14):W


Related Solutions

C++ Write a word search program that searches an input data file for a word specified...
C++ Write a word search program that searches an input data file for a word specified by the user. The program should display the number of times the word appears in the input data file. In addition, the program should count and display the number of grammatical characters in the input data file. Your program must do this by providing the following function: void processFile(ifstream &inFile, string wordSearch, int &wordCount, int &grammaticalCount); void processFile(ifstream &inFile, string wordSearch, int &wordCount, int...
in basic c++ program please!! Write a word search and word count program. Assign the following...
in basic c++ program please!! Write a word search and word count program. Assign the following text to a string constant. For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life. For God did not send his Son into the world to condemn the world, but to save the world through him.Whoever believes in him is not condemned, but whoever does not believe stands...
Create C# code that can search a text file and output the data at the line...
Create C# code that can search a text file and output the data at the line number inputted and amount of entries needed. Example of call in command window: Search16s filename.txt 273   10 Where 273 is the line number to start the output from, and 10 is the number of sequences that the program should output. The number of sequences entered on call should always be a odd number or give an error in console. The output should also display...
(IN C) Program Question 2: Write a program that solves for c in the Pythagorean Theorem:...
(IN C) Program Question 2: Write a program that solves for c in the Pythagorean Theorem: a2 + b2 = c2 The user will enter values for a and b, and you will calculate c. All of this code will go in just one source file.
Create a program in C that counts the number of characters in a word when a...
Create a program in C that counts the number of characters in a word when a user inputs a string. Use stdin to read an input string. For example, if a user inputs: “The dog is good” the output should be a= [The], b=3 a= [dog], b=3 a= [ is], b=2 a= [good], b=4 a= [ ], b=0000 Take into account EOF. If an EOF is reached at the end of the string then the output should be 0000. (example...
Create a program in C that counts the number of characters in a word when a...
Create a program in C that counts the number of characters in a word when a user inputs a string. Use stdin to read an input string. For example, if a user inputs: “The dog is good” the output should be a= [The], b=3 a= [dog], b=3 a= [ is], b=2 a= [good], b=4 a= [ ], b=0000 Take into account EOF. If an EOF is reached at the end of the string then the output should be 0000. (example...
C++ Programming Create a C++ program program that exhibits polymorphism. This file will have three class...
C++ Programming Create a C++ program program that exhibits polymorphism. This file will have three class definitions, one base class and three derived classes. The derived classes will have an inheritance relationship (the “is a” relationship) with the base class. You will use base and derived classes. The base class will have at least one constructor, functions as necessary, and at least one data field. At least one function will be made virtual. Class members will be declared public and...
Create a c++ program with this requirements: Create an input file using notepad ( .txt )...
Create a c++ program with this requirements: Create an input file using notepad ( .txt ) . When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File”...
Write a C program that can search for a string within a text file, replace it...
Write a C program that can search for a string within a text file, replace it with another string and put results in a new file.
This is C++ Create a program that reads an HTML file and converts it to plain...
This is C++ Create a program that reads an HTML file and converts it to plain text. Console: HTML Converter Grocery List * Eggs * Milk * Butter Specifications: The HTML file named groceries.html contains these HTML tags: <h1>Grocery List</h1> <ul> <li>Eggs</li> <li>Milk</li> <li>Butter</li> </ul> When the program starts, it should read the contents of the file, remove the HTML tags, remove any spaces to the left of the tags, add asterisks (*) before the list items, and display the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT