Re: [QUIZ] Perl 'Easy' Quiz of the Week #2005-03-04
colin.rafferty-/PgpppG8B+R7qynMiXIxWgC/[email protected] Fri, 04 Mar 2005 10:44:49 -0500
| Newsgroups | gmane.comp.lang.perl.qotw.discuss |
|---|---|
| Message-ID | <vgvzmxjl8jy.wl%[email protected]> |
Roger Burton West wrote:
> Since nobody has posted a quiz for a while, here's mine. For a change
> from word puzzles, here's a number puzzle...
It's an interesting puzzle, but I'm not certain that it's an easy one.
Anyway, you left out what the inputs and outputs should look like.
I've written the constraints below, if you don't like them, give
yours.
> (1) Write a program to check the correctness of a solution.
The input to this program is on stdin, nine lines, each consisting of
nine numbers, each separated by a single space.
The output of the program is "good\n" for a correct solution, or
"bad\n" for an incorrect solution.
> (2) Write a solver. (There are several of these on-line already.)
The input to this program is on stdin, nine lines, each consisting of
nine squares, each separated by a single space. A square is either a
number or a dash. The input for the original example would be this:
- - 6 - - - - - 1
- 7 - - 6 - - 5 -
8 - - 1 - 3 2 - -
- - 5 - 4 - 8 - -
- 4 - 7 - 2 - 9 -
- - 8 - 1 - 7 - -
- - 1 2 - 5 - - 3
- 6 - - 7 - - 8 -
2 - - - - - 4 - -
The output of the program should be on stdout, of the form of the
input to program (1). In particular, assuming input.txt is a proper
input to this program, the output of the following form should be
"good\n":
cat input.txt | program2 | program1
> (3) Write a random puzzle generator.
This program should take a single argument on the command line, a
number between 0 and 81, and should generate something in the form of
the input to program (2). This should be solvable. In particular,
the output of the following form should be "good\n":
program3 24 | program2 | program1
# Colin