Sudoku solver - source code

This is the source code of the Sudoku solver here. The code here reads puzzles in from standard input instead of CGI. Apart from that, it is the same solver.

The solver takes nine lines of input, with nine characters in each line. Each character represents one cell, and can be a digit between 1 and 9 (to indicate that that cell should be set initially) or a dot (".") if the cell should initially be blank.

It outputs the first solution it finds. If it finds that the puzzle is impossible, it will exit without making any output.

This code is public domain. Do anything you like with it. It would be nice to know if you find it useful, though.

The solver was originally written in Python and then translated to C++. The C++ translation was done very quickly and isn't well-written, but the Python version should be fine. Here are the versions: