Problem Description In the CCC Word Hunt, words are hidden in a grid of letters. The…
- User
Problem Description In the CCC Word Hunt, words are hidden in a grid of letters. The letters of a hidden word always appear in order on horizontal, vertical, or diagonal line segments in one of two ways. One way is for the letters of a word to appear on one line segment. The other way is for the letters of a word to appear on one line segment up to some letter and then on a second line segment that forms a right angle at this letter. Given a grid of letters and a single word to search for, your job is to determine the number of times that particular word is hidden in the grid. Input Specification The first line of input will contain a string of distinct uppercase letters, W, representing the word you are to search for in the grid. The length of W will be at least two. The second line of input will be an integer R (1 R 100), where R is the number of rows in the grid. The third line of input will be an integer C (1 C 100), where C is the number of columns in the grid. The remaining input will provide the letters in the grid. It will consist of R lines, where each line contains C uppercase letters separated by single spaces
- Assistant
Constraints:
- The length of the word will be at least 2, and will consist of distinct uppercase letters.
- The number of rows, R, will be between 1 and 100 inclusive.
- The number of columns, C, will be between 1 and 100 inclusive.
- The grid will consist of R lines, each containing C uppercase letters separated by single spaces.
Note: It is not mentioned whether the grid is a rectangular grid or not.