Description
Sudoku is a very simple task. A Square Table with 9 rows and 9 columns are divided to 9 smaller squares 3x3 as shown on the figure. In some of the cells is written decimal digits from 1 to 9. The other cells is empty. The goal is to fill the empty cells with a decimal digits from 1 to 9, one digit per cell, and in such. Each column and in each marked a 3x3 subsquare, all of the digits from 1 through 9 to appear. Write a program to solve a given sudoku-task.
Input
The input data would start with the number of the the test cases. For each test case, 9 lines follow, corresponding to the rows of the table. On each line a string of exactly 9 decimal digits are given, corresponding to the cells in this line. If a cell is empty it's represented by 0.
Output
For each test case your program should print the solution in the same format as the input data. The empty cells has the filled according to the rules. If Solutions is isn't unique, then the program could print any one of the them.
Sample Input
1103000509002109400000704000300502006060000050700803004000401000009205800804000107
Sample Output
143628579572139468986754231391542786468917352725863914237481695619275843854396127
Hi
Main topic
Sudoku game. Rule: In 9*9 's lattice, give you some numbers in advance. You have to fill it up, and each number you fill must meet the following four constraints.
A. Peer not heavy;
B. The same column is not heavy;
C. Where the small squares are not heavy;
D. belongs to the [1,9] range.
Programming implementation. If there is more than one solution, the output can be any one.
Note:Q: In the process of Sudoku solution, I put the number of x,x in a position R row C to meet the a\b\c\d four constraints, then this step must be right? A: It's not necessarily the right answer. This, as of now is right, but in the subsequent fill in other squares will find some of the previous attempts are wrong, need to backtrack.
Backtracking-poj2676-sudoku