@@ -0,0 +1,1868 @@
+package problems;%0A%0Apublic class SudokuSolver %7B%0A    public void solveSudoku(char%5B%5D%5B%5D board) %7B%0A        if (board == null %7C%7C board.length != 9 %7C%7C board%5B0%5D.length != 9)%0A            return;%0A%0A        solve(board);%0A    %7D%0A%0A    final boolean solve(char%5B%5D%5B%5D B) %7B%0A        for (int i = 0; i %3C 9; i++) %7B%0A            for (int j = 0; j %3C 9; j++) %7B%0A                if (B%5Bi%5D%5Bj%5D != '.')%0A                    continue;%0A%0A                for (char c = '1'; c %3C= '9'; c++) %7B%0A                    B%5Bi%5D%5Bj%5D = c;%0A                    if (check(B, i, j) && solve(B))%0A                        return true;%0A                %7D%0A                B%5Bi%5D%5Bj%5D = '.';%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A    final boolean check(char%5B%5D%5B%5D b, int x, int y) %7B%0A        for (int i = 0; i %3C 9; i++) %7B%0A            if (i != x && b%5Bi%5D%5By%5D == b%5Bx%5D%5By%5D)%0A                return false;%0A            if (i != y && b%5Bx%5D%5Bi%5D == b%5Bx%5D%5By%5D)%0A                return false;%0A        %7D%0A%0A        for (int i = x - x %25 3; i %3C x - x %25 3 + 3; i++) %7B%0A            for (int j = y - y %25 3; j %3C y - y %25 3 + 3; j++) %7B%0A                if ((i != x %7C%7C j != y) && b%5Bi%5D%5Bj%5D == b%5Bx%5D%5By%5D)%0A                    return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        SudokuSolver ss = new SudokuSolver();%0A        String%5B%5D sa = %7B %22..9748...%22, %227........%22, %22.2.1.9...%22, %22..7...24.%22, %22.64.1.59.%22,%0A                %22.98...3..%22, %22...8.3.2.%22, %22........6%22, %22...2759..%22 %7D;%0A%0A        char%5B%5D%5B%5D board = new char%5B9%5D%5B9%5D;%0A        for (int i = 0; i %3C 9; i++) %7B%0A            for (int j = 0; j %3C 9; j++)%0A                board%5Bi%5D%5Bj%5D = sa%5Bi%5D.charAt(j);%0A        %7D%0A        ss.solveSudoku(board);%0A        for (int i = 0; i %3C 9; i++) %7B%0A            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%0A    %7D%0A%7D%0A

Add Sudoku Solver