Menu
Question Index
...


Write a program to complete given Sudoku puzzle.

Input (Two Dimensional matrix) Output (Two Dimensional matrix)
0 0 6 5 0 8 4 0 0
5 2 0 0 0 0 0 0 0
0 8 7 0 0 0 0 3 1
0 0 3 0 1 0 0 8 0
9 0 0 8 6 3 0 0 5
0 5 0 0 9 0 6 0 0
1 3 0 0 0 0 2 5 0
0 0 0 0 0 0 0 7 4
0 0 5 2 0 6 3 0 0
3 1 6 5 7 8 4 9 2
5 2 9 1 3 4 7 6 8
4 8 7 6 2 9 5 3 1
2 6 3 4 1 5 9 8 7
9 7 4 8 6 3 1 2 5
8 5 1 7 9 2 6 4 3
1 3 8 9 4 7 2 5 6
6 9 2 3 5 1 8 7 4
7 4 5 2 8 6 3 1 9
0 0 0 2 0 0 0 6 3
3 0 0 0 0 5 4 0 1
0 0 1 0 0 3 9 8 0
0 0 0 0 0 0 0 9 0
0 0 0 5 3 8 0 0 0
0 3 0 0 0 0 0 0 0
0 2 6 3 0 0 5 0 0
5 0 3 7 0 0 0 0 8
4 7 0 0 0 1 0 0 0
8 5 4 2 1 9 7 6 3
3 9 7 8 6 5 4 2 1
2 6 1 4 7 3 9 8 5
7 8 5 1 2 6 3 9 4
6 4 9 5 3 8 1 7 2
1 3 2 9 4 7 8 5 6
9 2 6 3 8 4 5 1 7
5 1 3 7 9 2 6 4 8
4 7 8 6 5 1 2 3 9

class CompleteSudokuPuzzle

{    public static void main(String s[])
    {
        int[][] sudoku = {{0, 0, 0, 2, 0, 0, 0, 6, 3}, {3, 0, 0, 0, 0, 5, 4, 0, 1}, {0, 0, 1, 0, 0, 3, 9, 8, 0}, {0, 0, 0, 0, 0, 0, 0, 9, 0}, {0, 0, 0, 5, 3, 8, 0, 0, 0}, {0, 3, 0, 0, 0, 0, 0, 0, 0}, {0, 2, 6, 3, 0, 0, 5, 0, 0}, {5, 0, 3, 7, 0, 0, 0, 0, 8}, {4, 7, 0, 0, 0, 1, 0, 0, 0}};
        solveSudoku(sudoku);
        for (int[] array1d : sudoku) {
        for (int element : array1d) {
        System.out.print(element + " ");
        }
        System.out.println();
        }

    }


public static void solveSudoku(int[][] sudoku) {
//Write code here to fill empty positions in Sudoku puzzle
}

//If required, write any additional methods here
}

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App