Hey I’m having trouble getting my code to compare the integers of a given row or column and block to make sure there are no duplicates within those parameters. I don’t know if it would be a good idea separating the three contraints in 3 different methods or just trying to attempt to do all at once.
public static rowCheck(int[][] nsudokuBoard) {
for (int i =0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
// (nsudokuBoard)
}
}
}
this is my code im starting. before you guys bash on me for not even being able to compile this im stuck on how to compare all the values of a row of the 2d array.
You can compare all the values of the 2d array as shown in the code below:
I haven’t tried to compile this code, but it should give you an idea of how to accomplish your task. I would suggest that rather than passing in
int[][] sudokuBoardthat you should define a class which encapsulates the concept of aSudokuSquareand pass inSudokuSquare[][], that way yourvalidatemethod can return aList<SudokuSquare>containing all the offending entries.