だから私は自分のコードを更新しましたが、完成した数独ボード内の 3x3 ブロックをチェックして、繰り返し番号がないかどうかを確認する方法にまだ困惑しています。これは私が更新した私の方法です。
static boolean isBlock1Valid(int[][] sudokuBoard, int referenceRow, int referenceColumn)
{
boolean[] seen = new boolean[9];
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
if ( seen(sudokuBoard[referenceColumn+i][referenceRow+j])) return false;
else ( seen(sudokuBoard[referenceColumn+i][referenceRow+j])) = true;
}
}
return true;
}//end of isBlock1Valid
これは呼び出しメソッドです。メソッドに送信するパラメーターがわかりません isBlock1Valid
public static void Validate(final int[][] sudokuBoard)
{
int width = sudokuBoard[0].length;
int height = sudokuBoard.length;
for(int i = 0; i < width; i++)
if(!IsValidRow(sudokuBoard, i, width))
{
System.out.print("Invalid entry found \n (Row)" + "\t"+ i + "\n");
//Do something - The row has repetitions
}
else{
System.out.print("Row " +i + " is valid \n");
}
for(int j = 0; j < height; j++)
if(!IsValidColumn(sudokuBoard, j, height))
{
System.out.print("(Column)" + j + "\n");
//Do something - The columns has repetitions
}
else{
System.out.print("Column " +j +" is valid \n");
}
for(int i=0; i<2; i++)
if(!IsBlock1Valid(sudokuBoard,i, j)){
System.out.print("hi");
}
}