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:y c o d e j h s e y p k l p h b w a l o b w x z w o b a a i p l y y c g
y c o d e jNotice that this row contains the words cod, code, and ode. Suppose that the row is represented as the list [‘y’, ‘c’, ‘o’, ‘d’, ‘e’, ‘j’]. A simple way to explore all the possible words (going L to R) in this list would be as follows (the process for the other rows is similar).
j e d o c yand then searching left to right (a problem you’ve solved already). The key thing to note here is that you’ve taken the problem of searching R-to-L and converted it into an equivalent problem involving an L-to-R search, for which you’ve already written code.