• Rotate the grid 90, 180, or 270 degrees.
• Flip the board horizontally or vertically
• Permute the rows 1-3, 4-6, or 7-9.
• Permute the columns 1-3, 4-6, or 7-9.
• Permute the 3x9 blocks of rows.
• Permute the 9x3 blocks of columns.
• Permute the digits.
solve / transform / generate
To prevent rewriting code, you can write your sudoku code in sudoku.h / sudoku.cpp
3 0 2 0 0 5 6 9 0
0 4 0 0 9 6 0 3 0
0 5 0 0 0 8 0 0 0
1 9 0 0 8 0 7 0 3
0 0 0 0 0 0 0 0 0
5 0 7 0 3 0 0 6 1
0 0 0 8 0 0 0 2 0
0 8 0 9 6 0 0 7 0
0 6 5 7 0 0 3 0 9
digit is split with single space (' ')
each line end with newline ('\n')
$ ./generate
3 0 2 0 0 5 6 9 0
0 4 0 0 9 6 0 3 0
0 5 0 0 0 8 0 0 0
1 9 0 0 8 0 7 0 3
0 0 0 0 0 0 0 0 0
5 0 7 0 3 0 0 6 1
0 0 0 8 0 0 0 2 0
0 8 0 9 6 0 0 7 0
0 6 5 7 0 0 3 0 9
0 (finish, print it out)
1 x y (changeNum, {x,y = 1~9})
2 x y (changeRow, {x,y = 0,1,2})
3 x y (changeCol, {x,y = 0,1,2})
4 x (clockwise rotate 90 degree x times)
5 x (0 is up-down flip, 1 is left-right flip)
3 0 2 0 0 5 6 9 0
0 4 0 0 9 6 0 3 0
0 5 0 0 0 8 0 0 0
1 9 0 0 8 0 7 0 3
0 0 0 0 0 0 0 0 0
5 0 7 0 3 0 0 6 1
0 0 0 8 0 0 0 2 0
0 8 0 9 6 0 0 7 0
0 6 5 7 0 0 3 0 9
1 1 9
0
3 0 2 0 0 5 6 1 0
0 4 0 0 1 6 0 3 0
0 5 0 0 0 8 0 0 0
9 1 0 0 8 0 7 0 3
0 0 0 0 0 0 0 0 0
5 0 7 0 3 0 0 6 9
0 0 0 8 0 0 0 2 0
0 8 0 1 6 0 0 7 0
0 6 5 7 0 0 3 0 1
Input Output
3 0 2 0 0 5 6 9 0
0 4 0 0 9 6 0 3 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 0 2
7 9 8 0 0 0 0 0 0
0 6 0 3 0 8 0 9 0
0 0 0 0 0 0 8 6 5
3 0 0 0 0 7 0 0 6
0 7 2 6 0 0 0 3 9
9 0 0 1 0 3 0 0 0
5 1
0
3 0 0 1 0 5 0 0 0
0 4 5 9 0 0 0 8 6
2 0 0 0 0 7 0 0 5
0 0 0 0 0 0 8 9 7
0 9 0 8 0 3 0 6 0
5 6 8 0 0 0 0 0 0
6 0 0 7 0 0 0 0 3
9 3 0 0 0 6 2 7 0
0 0 0 3 0 1 0 0 9
Input Output
0 0 0 5 0 1 0 0 3
6 8 0 0 0 9 5 4 0
5 0 0 7 0 0 0 0 2
7 9 8 0 0 0 0 0 0
0 6 0 3 0 8 0 9 0
0 0 0 0 0 0 8 6 5
3 0 0 0 0 7 0 0 6
0 7 2 6 0 0 0 3 9
9 0 0 1 0 3 0 0 0
1 1 3
2 0 2
5 1
0
6 0 0 7 0 0 0 0 1
9 1 0 0 0 6 2 7 0
0 0 0 1 0 3 0 0 9
0 0 0 0 0 0 8 9 7
0 9 0 8 0 1 0 6 0
5 6 8 0 0 0 0 0 0
1 0 0 3 0 5 0 0 0
0 4 5 9 0 0 0 8 6
2 0 0 0 0 7 0 0 5
Input Output
Example output
// Has unique solution
1
3 7 2 1 4 5 6 9 8
8 4 1 2 9 6 5 3 7
9 5 6 3 7 8 2 1 4
1 9 4 6 8 2 7 5 3
6 3 8 5 1 7 9 4 2
5 2 7 4 3 9 8 6 1
7 1 9 8 5 3 4 2 6
2 8 3 9 6 4 1 7 5
4 6 5 7 2 1 3 8 9
// No solution
0
// Has multiple solution
2
astyle --style=google --indent=spaces=4 --suffix=none <file>