Answered You can hire a professional tutor to get the answer.
//check a 9*9 sudoku //Returns true if this grid is legal. A grid is legal if no row, column, or // 3x3 block contains a repeated 1, 2, 3, 4, 5, 6,...
//check a 9*9 sudoku
//Returns true if this grid is legal. A grid is legal if no row, column, or
// 3x3 block contains a repeated 1, 2, 3, 4, 5, 6, 7, 8, or 9.
// *** I Have already done to check row, and column but I have no idea how to check if it has legal 3*3 block in 9*9 sudoku
// Only need help to do the last part, check the block
public boolean isLegal()
{
// Check every row. If you find an illegal row, return false.
for(int i=0; i<values.length; i++)
{
for(int j=0; j<values[0].length; j++)
{
int num = values[i][j];
for(int col=j+1; col<values[0].length; col++)
{
if(num == values[i][col])
{
return false;
}
}
}
}
// Check every column. If you find an illegal column, return false.
for(int i=0; i<values.length; i++)
{
for(int j=0; j<values[0].length; j++)
{
int num = values[i][j];
for(int row=i+1; row<values.length; row++)
{
if(num == values[row][j])
{
return false;
}
}
}
}
// Check every block. If you find an illegal block, return false.
// need help!