Write a program to produce a file containing a crossword grid that the user can print out and work the puzzle on.
Input
A filename representing a crossword grid file and optionally a second filename representing a crossword numbering file. The input should be accepted by a conventional means for your programming environment: command line arguments, the standard input, web forms, etc..
You may assume that the crossword has been validated, and if using a numbering file that is corresponds to the grid provided.
Grid file format: The first line consists of two white-space
separated integer constants M and N. Following that line are M
lines each consisting of N characters (plus a new line) selected
from [#A-Z ]
. These characters are interpreted such that '#'
indicates a blocked square, ' '
a open square in the puzzle
with no known contents and any letter an open square whose
containing that letter.
Numbering file format Lines starting with '#' are ignored and
may be used for comments. All other lines contain a tab separated
triplet i
, m
, n
where i
represents a number to be printed
on the grid, and m
and n
represent the row and column of the
square where it should be printed. The number of both rows and
columns starts at 1.
Output
The output will be a file that the user can print out and work a crossword on. ASCII, postscript, pdf, png, and any other reasonable format will be accepted, but all must abide by these rules:
- There must be a rule around the entire puzzle and between every pair of squares.
- Blocked squares must be filled in darkly.
- In play square that represent the start of a numbered (across or down) clue must be provided with a number in the upper, left corner of the square, while leaving most of the square blank for the play to write in. Note that typical grid published in the papers will have many tens of clues and may have more than 100.
The output will be of the grid alone, without the list of clues.
Output should be sent to a conventional destination (a file whose name is derived from the input filename, produced as a web page, etc..)
Test case
Given a input of
5 5
# ##
#
#
#
## #
the starting corner of an acceptable ASCII output might look like this
+-----+-----+-----+---
|#####|1 |2 |###
|#####| | |###
|#####| | |###
+-----+-----+-----+---
|#####|3 | |4
|#####| | |
|#####| | |
+-----+-----+-----+---
|6 | |#####|
| | |#####|
Those using graphical formats should take their inspiration from the usual printed sources.
Numbering scheme
A correctly numbered grid has the following properties:
- Numbering begins at 1.
- No column or span of open squares is unnumbered.
- Numbers will be encountered in counting order by scanning from top row to the bottom taking each row from left to right.
Aside
This is the third of several crossword related challenges. I plan to use a consistent set of file-formats throughout and to build up a respectable suite of crossword related utilities in the process.
Previous challenges in this series: