Advertisement
Guest User

#1

a guest
Apr 7th, 2013
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. public void solveWithout(int row, int col) {
  2.     if(row > squares.length - 1) {
  3.         solutions.insert(squares);
  4.         return;
  5.     }
  6.  
  7.     if(squares[row][col] instanceof PrefilledSquare)
  8.         nextWithout(row, col);
  9.     else {
  10.         for (int value = 1; value <= squares.length; value++) {
  11.             if(squares[row][col].legalValue(value)) {
  12.                 squares[row][col].setValue(value + "");
  13.                 nextWithout(row, col);
  14.             }
  15.         }
  16.         squares[row][col].setValue(0 + "");
  17.        }
  18.     }
  19.        
  20.  
  21. public void nextWithout(int row, int col) {
  22.     if(col < squares.length - 1)
  23.         solveWithout(row, ++col);
  24.     else
  25.         solveWithout(++row, 0);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement