File Names Your program should be in a file named word_seareh. py. (NOTE: use an underscore in the filename, not a dash.) Expected Behavior Write a program, in a file named word_search.pY, to do the following: second as a grid-of-letters file. - Read the word-list file into a list and the grid-of-lefters file into a square grid. You may assume that these files are organized as follows: the word-list file contains one word per line; - the grid-of-letters consists of \( N \) lines, each line consisting of \( N \) letters separated by whitespace. - Search this grid for logal words. Matches of words found in the grid against those in the list-ol-words should be case-insensitive. - Collect the legal words found into a list and then print them out as indicaled under Output format below. Examples The following is an example of the grid of letters file: \[ \begin{array}{llllll} y & c & o & d & e & j \\ h & 5 & e & y & p & k \\ 1 & p & h & b & w & a \\ 1 & \circ & b & w & x & z \\ w & \circ & b & a & a & i \\ p & l & y & y & c & g \end{array} \] In this example (and as your program can figure out after reading the first line), \( N=6 \). For this grid, the words your program should print out are: - code, cod, ode, lob (horizontal, L-to-R) - bow, yes, doc (horizontal, R-to-L) - spool, pool, way (vertical, top-to-bottomi) - loop, locps (vertical, bottom-to-top) - lob, wag (diagonal, top-left to bottom-right)
using your own word-lists, which can be bigger or smaller than this list and whose words that may or may not be real English words. Output format The words you find should be printed in alphabetical order, one to a line without any extra whitespace. Development Strategy Data Structures Organize the list of valid words as a list of strings. Organize the grid as a list of lists. Program development 1. Write a function occurs_in ( substy word_list) ) that indicates whether the string substr occurs in a list of words word_list ignoring upperiower case differences. 2. Searching horizontally. First, consider the problem of finding words horizontally in the grid going from left to right. Consider the first row in the example shown above: \[ y=0 d e j \] follows (the process for the other rows is similar). for length 5 , etc., until you reach the end of the list. - Now repeat this step, but starting at the second element (i.e., 'c'). Notice that this time you will come to the end of the list one step sooner. Then repeat for the third element, and so on. concit list ( ) from the Short Problems for this assignment? Next consider the problem of searching for words horizontally going right to left, Suppose we want to search the row \( y \mathrm{c} \) o \( d \) a \( j \) going right to left. This is actually the same as reversing the row, to jedocy already written code. bottom? Can you figure out a way of using column2list () with list-reversing to solve the problem of searching vertically going from bottom to top? 4. Searching diagonally. Searching diagonally is the hardest part of this problem, however, we are only considering one case: upper-left to lower-right.
- If you can extract each diagonal into a list of letters, then you can simply search through this list as you did before-again, reducing this problem to one you've already written code to solve. you go from one element to the next? Why do they change in this way? .... How do the \( x \) - and \( y \)-coordinates change as you go from one element to the next? Why do they change in this way? diagonals you considered (above)?