|
|||
Word SearchThis problem involves those classic word search puzzles that you did when you were a kid (or maybe still do). The input will consist of several word search puzzles, each one consisting of a square grid of letters and a list of words to find. In this particular problem, your program should search for words up, down, left, and right. If a word is not found, a message should reflect this. You may assume that no word will be found more than once. Input SpecificationThe input data will contain an arbitrary number of test cases, followed by a line containing a single 0. Each test case will have the following format: The first line consists of a decimal integer N, between 5 and 10 inclusive, representing the dimensions of the grid. Following this are N rows of N capital letters. There are no spaces in the row, and each row is terminated by a newline character. The next line consists of a decimal integer M, between 1 and 15 inclusive, representing the number of words to search for. Following this are M words, each word containing between 3 and 8 capital letters inclusive. There are no spaces within the words, and each word is terminated by a newline character. There may or may not be one or more additional newline characters separating the test cases, or between the final test case and the terminating 0, but no superfluous newline characters will appear within a test case. Output Specification
The test cases should appear in the output in the order in which they appear in the input.
The output for each test case will consist of M lines (M defined above).
Each line should begin with the word being searched for (and these words should appear in the
output in the order in which they appear in the input). If the word is present in the grid,
the word should be followed by the column number and the row number of the first letter in
the word (the upper left corner is row 1, column 1) and the direction ( Sample Input
Output for Sample Input
Original Problem |
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |