library(sudoku)
d<-generateSudoku()
printSudoku(d)
## +-------+-------+-------+
## | | 5 | 3 |
## | 1 8 5 | 3 | 2 |
## | 9 | 4 | 5 |
## +-------+-------+-------+
## | 3 | 2 | 5 8 |
## | 5 1 | 9 | 2 |
## | | 8 | 3 |
## +-------+-------+-------+
## | 1 | 9 6 | 4 7 |
## | 3 | 4 | 1 |
## | 2 | 8 | 3 |
## +-------+-------+-------+
d<-solveSudoku(d)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
## [1,] 2 4 7 1 5 8 3 9 6
## [2,] 1 8 5 3 6 9 2 7 4
## [3,] 6 3 9 7 4 2 8 1 5
## [4,] 4 7 3 6 2 1 9 5 8
## [5,] 5 1 8 4 9 3 7 6 2
## [6,] 9 6 2 5 8 7 1 4 3
## [7,] 8 5 1 9 3 6 4 2 7
## [8,] 3 9 6 2 7 4 5 8 1
## [9,] 7 2 4 8 1 5 6 3 9
printSudoku(d)
## +-------+-------+-------+
## | 2 4 7 | 1 5 8 | 3 9 6 |
## | 1 8 5 | 3 6 9 | 2 7 4 |
## | 6 3 9 | 7 4 2 | 8 1 5 |
## +-------+-------+-------+
## | 4 7 3 | 6 2 1 | 9 5 8 |
## | 5 1 8 | 4 9 3 | 7 6 2 |
## | 9 6 2 | 5 8 7 | 1 4 3 |
## +-------+-------+-------+
## | 8 5 1 | 9 3 6 | 4 2 7 |
## | 3 9 6 | 2 7 4 | 5 8 1 |
## | 7 2 4 | 8 1 5 | 6 3 9 |
## +-------+-------+-------+