Guest User

Untitled

a guest
Feb 14th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public class Sudoku {
  2. private int[][] grid = new int[9][9];
  3. private int col;
  4. private int row;
  5.  
  6. public boolean solveSudoku() {
  7. if(!(this.FindEmptyCell())) {
  8. return true;
  9. }
  10.  
  11. for(int num = 1; num <= 9; num++) {
  12. if(this.isPossible(this.col, this.row, num)) {
  13. this.grid[this.col][this.row] = num;
  14. if(this.solveSudoku()) {
  15. return true;
  16. }
  17. this.grid[col][row] = 0;
  18. }
  19. }
  20. return false;
  21. }
  22. }
  23.  
  24. 1 2 3 4 5 6 7 8 9
  25. 4 5 6 1 2 3 0 0 0
  26. 0 0 0 0 0 0 0 0 0
  27. 0 0 0 0 0 0 0 0 0
  28. 0 0 0 0 0 0 0 0 0
  29. 0 0 0 0 0 0 0 0 0
  30. 0 0 0 0 0 0 0 0 0
  31. 0 0 0 0 0 0 0 0 0
  32. 0 0 0 0 0 0 0 0 0
Add Comment
Please, Sign In to add comment