Editorial for CCC '23 J5 - CCC Word Hunt


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

The intended challenge of the final problem in this year's competition was different in nature than the last few years. Here, systematically considering each possible placement of the word in the grid will earn full marks if implemented correctly. In fact, it is not possible to solve this problem more efficiently. What some participants may have found difficult is coding this algorithm or approach so that it works correctly in all cases.

We need to carefully consider all possible starting locations of the word and each possible direction from each of these locations. The number of possibilities increases from subtask to later subtask.

Other than for the first subtask, the grid must be stored in memory. It is a two-dimensional structure so a data structure such as a list of lists (or array of arrays) is needed. It is easy to make errors "around the edge of the grid". Care must be taken to only access valid locations within the data structure of choice.

For this last subtask, the possibility of perpendicular bends in the hidden word presents a significant additional challenge because the number of possible locations for the hidden word is quite large. This can result in long repetitive code with lots of cases which is very error-prone. Carefully designed functions with well-chosen parameters can help remove lots of the redundancy reducing the likelihood of errors and simplifying the process of debugging if errors do occur.


Comments

There are no comments at the moment.