Question: Please note that for the first sample run shown above, the path output is not unique, but your solution needs to output only one of


Please note that for the first sample run shown above, the path output is not unique, but your solution needs to output only one of the many viable paths if those paths overlap in the first letter ('H').

For the second sample run, finding the word in the puzzle involves backtracking. Your solution must print the path as shown. Here 642 denotes that the character at this location is the 2nd, 4th and 6th in the search path. Your program may also output 246 instead of 642 at this location (and subsequently, 35 instead of 53 at the other location shown in the output).
wordsearch.c
#include #include #include // Declarations of the two functions you will implement // Feel free to declare any helper functions or global variables void printPuzzle(char** arr); void searchPuzzle(char** arr, char* word); int bSize; // Main function, DO NOT MODIFY int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Usage: %s ", argv[0]); return 2; } int i, j; FILE *fptr; // Open file for reading puzzle fptr = fopen(argv[1], "r"); if (fptr == NULL) { printf("Cannot Open Puzzle File! "); return 0; } // Read the size of the puzzle block fscanf(fptr, "%d ", &bSize); // Allocate space for the puzzle block and the word to be searched char **block = (char**)malloc(bSize * sizeof(char*)); char *word = (char*)malloc(20 * sizeof(char)); // Read puzzle block into 2D arrays for(i = 0; i
// in the instructions. // Your implementation here... } void searchPuzzle(char** arr, char* word) { // This function checks if arr contains the search word. If the // word appears in arr, it will print out a message and the path // as shown in the sample runs. If not found, it will print a // different message as shown in the sample runs. // Your implementation here... }
Puzzle1.txt
5 W E B M O I L H L L M L Z E L M Y E K O A O A B A
Puzzle2.txt
6 J Z I M O B O T H N G A E R B Q P D M A E K O Z A T N R A E E N O B T K
Puzzle3.txt
5 J Z I D O E T H N E E R Z T R M D P K O A T F R A
The main program (wordsearch. c) is given to you below. Your primary task is to implement the searchPuzzle () function to complete the program. When the program starts, it will read the puzzle grid from a text file and save it as a 2D character array. The first number in the text file containing the puzzle grid indicates the size of the grid. For instance, a 5 means the puzzle is a 55 grid. The program will then ask the user for the word to search and store it in the variable word. This program should then print the original puzzle grid and search for the word in the puzzle. The program should finally print whether the search is found, and if so, the search path as described below. Task: searchPuzzle (char**, char ) This function is the core of solving the puzzle. It takes in the puzzle grid to find the search word input by the user (the 2nd argument) and prints the phrase word found! and the path(s) if the word is found. If the word is not found, then it prints Word not found. The search will happen in a case insensitive manner and all directions are allowed. The letters in the found word (i.e the path) must be one index away from each other either in row or column or both (or in simpler terms, adjacent to each other) as shown in the sample runs. - DO NOT USE ARRAY NOTATION ( []) - DO NOT USE ANY LIBRARY FUNCTIONS TO CONVERT CHARACTERS INTO LOWERCASE OR CAPITAL LETTER - OUTPUT FORMATTING MUST MATCH THE SAMPLE RUNS EXACTLY (SPACING, SPELLING, NEWLINES, ETC.) - FEEL FREE TO CREATE ADDITIONAL FUNCTIONS OR ARRAYS Printing puzzle before search: W E B M O I L H L L M L Z E L M Y E K O A O A B A Enter the word to search: bAnANa Printing puzzle before search