Question: 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
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
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 c o d e j
Now repeat this step, but starting at the second element iec 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
Next consider the problem of searching for words horizontally going right to left. Suppose we want to search the row y c d e j going right to left. This is actually the same as reversing the row, to
docy bottom to top?
Searching diagonally. Searching diagonally is the hardest part of this problem, however, we are only considering one case: upperleft to lowerright.
If you can extract each diagonal into a list of letters, then you can simply search through this list as you did beforeagain, reducing this problem to one you've already written code to solve.
Repeat this exercise for the diagonal starting at grid Look at how the and coordinates change from each element to the next. How does this compare to the way they changed for the other two diagonals you considered above
Do you see a pattern in how the and coordinates change between successive elements? Can you use this pattern to extract a diagonal going from the upperleft to lowerright given its starting coordinates into a list?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
