Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Sudoku {
- private int[][] grid = new int[9][9];
- private int col;
- private int row;
- public boolean solveSudoku() {
- if(!(this.FindEmptyCell())) {
- return true;
- }
- for(int num = 1; num <= 9; num++) {
- if(this.isPossible(this.col, this.row, num)) {
- this.grid[this.col][this.row] = num;
- if(this.solveSudoku()) {
- return true;
- }
- this.grid[col][row] = 0;
- }
- }
- return false;
- }
- }
- 1 2 3 4 5 6 7 8 9
- 4 5 6 1 2 3 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0
Add Comment
Please, Sign In to add comment