Crossword
(Challenge added 2028 days ago.)
Only drawing them, not solving them ... yet!
The Problem
Today, we'll be drawing some crosswords in ASCII according to the simple rules below.
(Before we get started, Some people may recognise the challenge as being the same as Ruby Quiz #10. A reminder though - Instead of the nice, elegant solutions submitted to Ruby Quiz, we're after the shortest, nastiest ones here!)
The rules are as follows :
You will receive a crossword grid on stdin. Your program should draw a larger representation of this grid, complete with numbers for the clues, on stdout.
The grid will consist of multiple lines containing capital Xs ("
X") and underscores (_). AnXdenotes a filled-in square, and an_is a blank square. Any whitespace within each line should be ignored. An example grid would be_____X_ _XX_XX_ _X_____
For each
X, you should output###### ###### ###### ######
and for each blank square, you should output
###### # # # # ######
When combining squares, you should collapse the borders together so that the grid
__ X_
would look like
########### # # # # # # ########### ###### # ###### # ###########
You should drop any filled-in squares which form the outer age of the crossword.
So,
X_X ___
would be rendered as
###### # # # # ################ # # # # # # # # ################The final step is to add numbers to indicate where the clues fit into the crossword. A square is numbered if it is the start of a word going either left to right, or from top to bottom. Numbers start at 1, and increase left to right, top to bottom and should be placed so there are no spaces between the number and the border to the left.
So, the previous diagram with clue numbers included would look like
###### #1 # # # ################ #2 # # # # # # # ################
Other Information
- Your program will be ran four times with various grids. See below for the grids your code will be given.
Examples
These are the grids that will be given to your program and the expected output for each of the four runs :
