Validate a proposed crossword grid.
Entries should be full programs that simply test a proposed grid to determine if it meets a set of conditions for making crossword solvers happy.
The input will be the name of a file representing the crossword grid. The input filename may be passed as an argument, on the standard input, or by other conventional means other than hardcoding.
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
[#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.
The program should produce no output on valid grids and exit with normal termination state. If the proposed grid fails, the program should produce a diagnostic error message and exit with a abnormal termination state (i.e. not 0 on unix) if this is supported by your execution environment. The error message should indicate both which condition for validity is violated and the location of the offending square; you are free to chose the means of conveying these facts.
Conditions for validity
Valid grids will have no answers (across or down) that are only 1 character long (extra credit for making the minimum length a input parameter), and will exhibit the usual symmetry. The usual symmetry means the crossword remains the same after (three equivalent descriptions of the same operation):
- reflection through it's own center
- reflection both vertically and horizontally
- 180 degree rotation
Test input and expected output
5 5 # ## # # # ## #
Fails on short answer:
5 5 ## ## # # # ## ##
Fails on symmetry:
5 5 # ## # # # # ## #
This is the second 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. For instance a subsequent puzzle will call for printing a ASCII version of the crossword based on the input and output of this puzzle.
Previous challenges in this series: