Write a program to check if the number is accepted at the given 2x3 sudoku position. The empty positions are marked as 0.
Input (int[][],int number, SudokuPosition) | Output (Boolean) |
---|---|
0 0 2 4 0 0 |
false |
0 1 3 0 0 0 |
true |
class IsNumberAcceptedAt2x3SudokuPosition
{ public static void main(String s[])
{
int[][] sudoku = {{1, 0, 2, 4, 0, 0}, {0, 0, 0, 0, 0, 6}, {0, 3, 0, 0, 0, 5}, {2, 0, 0, 0, 4, 0}, {4, 0, 0, 0, 0, 0}, {0, 0, 1, 6, 0, 0}};
System.out.println("2 can be placed at position [3, 4] : " + isNumberPlacedAtGivenPosition(sudoku, 2, new SudokuPosition(3, 4)));
}
public static boolean isNumberPlacedAtGivenPosition(int[][] sudoku, int number, SudokuPosition sudokuPosition) {
//Write code here to check if the number is accepted at the given 2x3 sudoku position.
}
}
class SudokuPosition {
int rowPosition;
int columnPosition;
public SudokuPosition(int rowPosition, int columnPosition) {
this.rowPosition = rowPosition;
this.columnPosition = columnPosition;
}
}