Tight-Fit Sudoku
Time limit2sMemory limit512 MB
Fill a 6 by 6 grid with digits 1 to 9 so no digit repeats in a row, column, or 3 by 2 box, including split squares holding two digits.
- Level
Medium7 of 10
- Topics
- Backtracking, Implementation, Matrix
- Solved
- No attempts yet
Problem
At some point or another, most computer science students have written a standard Sudoku solving program. A slight twist has been added to standard Sudoku to make it a bit more challenging.
Digits from 1 to 9 are entered in a grid so that no number is repeated in any row, column, or outlined region. A region is 3 squares wide and 2 squares tall; splitting the grid into groups of 2 rows from the top and groups of 3 columns from the left gives the 6 regions. Some squares in the grid are split by a slash (/) and need 2 digits entered in them. The smaller number always goes above the slash.


Write a program that takes an incomplete puzzle grid as input and outputs the puzzle solution grid.
Input
The first line of input contains a single decimal integer (), the number of data sets that follow.
Each data set should be processed identically and independently. Each data set consists of 7 lines of input. The first line of the data set contains the data set number, . The remaining 6 lines represent an incomplete Tight-Fit Sudoku grid; each line has 6 data elements, separated by spaces. A data element is a digit (1 to 9), a - for a blank square, or two of these joined by a slash (/). An element with a slash is a split square: the part before the slash is the upper half, and the part after it is the lower half.
Every grid has exactly one solution.
Output
For each data set there are 7 lines of output. The first output line is the data set number, . The following 6 lines show the solution grid for that data set. Each line has 6 data elements, separated by spaces. A data element is a single digit (1 to 9) or 2 digits separated by a slash (/). For a split square, write the smaller digit before the slash.