Advertisement
vladimirVenkov

sudioku partially

Jun 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. public static final int SIZE = 9;
  2.  
  3. public static boolean solve(int[][] s) {
  4.  
  5.     for (int i = 0; i < SIZE; i++) {
  6.         for (int j = 0; j < SIZE; j++) {
  7.             if (s[i][j] != 0) {
  8.                 continue;
  9.             }
  10.             for (int num = 1; num <= SIZE; num++) {
  11.                 if (isValid(num, i, j, s)) {
  12.                     s[i][j] = num;
  13.                     if (solve(s)) {
  14.                         return true;
  15.                     } else {
  16.                         s[i][j] = 0;
  17.                     }
  18.                 }
  19.             }
  20.             return false;
  21.         }
  22.     }
  23.     return true;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement