0

Hello all!

New here at daniweb.

I am working on a function to check the validity of a sudoku puzzle. It must check the 9x9 matrix to make sure it follows the rules and is a valid sudoku puzzle.

this is what I have come up with so far:

```
/** Check whether grid[i][j] is valid in the grid */
bool isValid(int grid[] [9])
{
int i, j;
bool status;
status = true;
for (int column = 0; column < 9; column++)
if (column != j && grid[i] [column] == grid[i] [j])
status = false;
for (int row = 0; row < 9; row++)
if (row != i && grid[row] [j] == grid[i] [j])
status = false;
for (int row = (i / 3) * 3; row < (i / 3) * 3 + 3; row++)
for (int col = (j / 3) * 3; col < (j / 3) * 3 + 3; col++)
if (row != i && col != j && grid[row] [col] == grid[i] [j])
status = false;
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++)
if (grid[i][j] != 0)
status = false;
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++)
if ((grid[i][j] < 0) || (grid[i][j] > 9))
status = false;
return status;
}
```

Any ideas?