package problems;

public class SudokuSolver {
    public void solveSudoku(char[][] board) {
        if (board == null || board.length != 9 || board[0].length != 9)
            return;

        solve(board);
    }

    final boolean solve(char[][] B) {
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                if (B[i][j] != '.')
                    continue;

                for (char c = '1'; c <= '9'; c++) {
                    B[i][j] = c;
                    if (check(B, i, j) && solve(B))
                        return true;
                }
                B[i][j] = '.';
                return false;
            }
        }
        return true;
    }

    final boolean check(char[][] b, int x, int y) {
        for (int i = 0; i < 9; i++) {
            if (i != x && b[i][y] == b[x][y])
                return false;
            if (i != y && b[x][i] == b[x][y])
                return false;
        }

        for (int i = x - x % 3; i < x - x % 3 + 3; i++) {
            for (int j = y - y % 3; j < y - y % 3 + 3; j++) {
                if ((i != x || j != y) && b[i][j] == b[x][y])
                    return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        SudokuSolver ss = new SudokuSolver();
        String[] sa = { "..9748...", "7........", ".2.1.9...", "..7...24.", ".64.1.59.",
                ".98...3..", "...8.3.2.", "........6", "...2759.." };

        char[][] board = new char[9][9];
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++)
                board[i][j] = sa[i].charAt(j);
        }
        ss.solveSudoku(board);
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++)
                System.out.print(board[i][j] + ", ");
            System.out.println();
        }
    }
}

@@ -12,16 +12,42 @@
 blems;%0A%0A
+import java.util.Arrays;%0A%0A
 public c
@@ -1730,34 +1730,32 @@
 = 0; i %3C 9; i++)
- %7B
 %0A            for
@@ -1755,133 +1755,54 @@
     
-for (int j = 0; j %3C 9; j++)%0A                System.out.print(board%5Bi%5D%5Bj%5D + %22, %22);%0A            System.out.println();%0A        %7D
+System.out.println(Arrays.toString(board%5Bi%5D));
 %0A   

Update Sudoku Solver