Problem D
Sudokunique
The popular game of Sudoku requires the player to fill in a $9$-by-$9$ board using the digits $1$ through $9$, such that no row, column, or $3$-by-$3$ square (see diagram) has more than one copy of each digit. The player is given a partially completed board and must fill in the blank squares. Designing a Sudoku puzzle appears easy – just start with a solved, valid puzzle, and erase the digits in some of the squares. However, if the designer erases too many squares, then there might be multiple solutions. This can make solving the puzzle more difficult, and potentially less fun. Thus, you should write a program to help a designer find out if their puzzle has exactly one solution.
3 |
5 |
7 |
4 |
9 |
1 |
6 |
2 |
8 |
9 |
2 |
4 |
8 |
6 |
7 |
3 |
5 |
1 |
6 |
1 |
8 |
5 |
2 |
3 |
4 |
7 |
9 |
1 |
6 |
9 |
2 |
7 |
5 |
8 |
3 |
4 |
7 |
4 |
5 |
9 |
3 |
8 |
1 |
6 |
2 |
8 |
3 |
2 |
6 |
1 |
4 |
7 |
9 |
5 |
2 |
9 |
1 |
3 |
8 |
6 |
5 |
4 |
7 |
5 |
7 |
6 |
1 |
4 |
2 |
9 |
8 |
3 |
4 |
8 |
3 |
7 |
5 |
9 |
2 |
1 |
6 |
Input
Input consists of up to $100$ Sudoku boards. Each board is given as a $9$-by-$9$ matrix using digits $0$ through $9$, one matrix row per line. If a board square contains $0$, that means it’s been erased. There is a blank line between pairs of boards. Input ends at end of file.
Output
For each board, if there is a unique solution, print the solution using the same format as the input. If there are multiple solutions, print “Non-unique”. If the designer has made a terrible mistake and there is no solution, print “Find another job”. Separate the outputs for adjacent cases with a blank line.
Sample Input 1 | Sample Output 1 |
---|---|
3 0 7 4 0 0 0 0 8 0 0 4 0 0 7 3 5 0 0 1 0 0 2 0 0 0 9 0 6 9 2 7 0 8 3 0 0 0 0 0 0 0 0 0 0 0 3 2 0 1 4 7 9 0 2 0 0 0 8 0 0 4 0 0 7 6 1 0 0 9 0 0 4 0 0 0 0 9 2 0 6 0 4 8 3 9 0 7 1 6 7 7 1 6 0 8 3 4 9 9 3 6 7 4 1 0 8 0 6 8 0 0 3 9 1 7 4 3 0 9 1 7 4 6 0 8 7 1 4 8 6 0 9 0 3 8 6 3 4 1 7 0 9 0 1 9 0 0 8 6 4 3 7 4 0 7 9 0 3 8 6 1 0 4 8 3 9 0 7 1 6 0 7 1 6 0 8 3 4 9 9 3 6 7 4 1 0 8 0 6 8 0 0 3 9 1 7 4 3 0 9 1 7 4 6 0 8 7 1 4 8 6 0 9 0 3 8 6 3 4 1 7 0 9 0 1 9 0 0 8 6 4 3 7 4 0 7 9 0 3 8 6 1 |
3 5 7 4 9 1 6 2 8 9 2 4 8 6 7 3 5 1 6 1 8 5 2 3 4 7 9 1 6 9 2 7 5 8 3 4 7 4 5 9 3 8 1 6 2 8 3 2 6 1 4 7 9 5 2 9 1 3 8 6 5 4 7 5 7 6 1 4 2 9 8 3 4 8 3 7 5 9 2 1 6 Find another job Non-unique |