Program / Task Name:

   Reverse Crossword

Level:

 

 Advanced

Point Value:

 

 17

 

Task Description

You will be given an n x m ASCII representation of a solved crossword puzzle.  Each single character represents a square of the crossword puzzle.  Blank spaces will be denoted by an asterisk (*).  Your job is to construct the list of words that make up the crossword answers.  Words must consist of at least two (2) letters and can run across from left to right or they may run down from top to bottom.   Each word should be printed along with its corresponding number.  A word’s number refers to the number of the square that contains the first letter of the word.  Squares should be numbered from left-to-right first, then top-to-bottom starting with number 1.  Only squares that start a word get a number.

Program Input

The first line of input file (prob15.in) will be two integers n and m separated by a single space denoting the number of rows and columns, respectively, in the crossword puzzle.  The next n lines contain m characters each and represent the solved crossword puzzle:

15 15
*t*s*o*e*f*g*m*
serendip*atonal
*n*r*y*s*g*i*g*
derbyshire*nero
*t***s*l*n*g*i*
ashore*obdurate
***d*u*n***o*t*
yiddish*accused
*a*f***s*o*n***
amnesiac*nodose
*b*l*b*h*t***t*
curl*icebreaker
*s*o*d*m*a*s*a*
peewee*escapade
*s*s*m*s*t*s*y*

Program Output

Your program should output the word “Across” on it’s own line followed by a line for each “across” number and word to prob15.out.  You should repeat the same pattern for the “down” words:

Across
8.      serendip
9.      atonal
10.     derbyshire
11.     nero
12.     ashore
14.     obdurate
15.     yiddish
17.     accused
20.     amnesiac
22.     nodose
24.     curl
25.     icebreaker
27.     peewee
28.     escapade
Down
1.      tenets
2.      serb
3.      odysseus
4.      epsilon
5.      fagend
6.      goinground
7.      magritte
13.     oddfellows
16.     iambuses
18.     contract
19.     schemes
21.     ibidem
23.     steady
26.     asps

 

 

   
  (c) 2004 Hewlett-Packard Company