# Help with Sudoku function please

• November 13th, 2011, 10:12 PM
peperez
Hi, I am trying to write a function that takes as input a double array [9][9] of integers (like a Sudoku board) and checks to see if every cluster of 9 squares is correct, meaning that no number is repeated. I am basically going through the cluster, putting the values into a temporary array (temp[]) and looping through temp[] to see if any number is repeated. I think my code is correct, but I am getting a "cannot find symbol, symbol: variable k". I am sure it is something really simple, but I've been working on this for over an hour and my eyes are just missing it. I'm sure someone can spot it right away.

Here is the function I've been working on:

Code :

```public boolean checkClusters(int[][] board) {   int[] temp = new int[9]; int counter = 0; int error = 0;   search: for (int i = 0; i < 9; i += 3) { for (int j = 0; j < 9; j += 3) {   for (int ii = 0; ii < 3; ii++) { for (int jj = 0; jj < 3; jj++) {   if (ii == 0) temp[ii + jj] = board[i + ii][j + jj]; else if (ii == 1) temp[2 + ii + jj] = board[i + ii][j + jj]; else if (ii == 2) temp[4 + ii + jj] = board[i + ii][j + jj];   for (int k = 0; k < 9; k++) for (int kk = 0; kk < k % 9; kk++) if (temp[k] == 0) break; if (temp[k] == temp[kk]) { error = 1; break search; } } } } } return error == 0; }```
• November 13th, 2011, 11:14 PM
peperez
Re: Help with Sudoku function please
bump, bump
• November 13th, 2011, 11:40 PM
Actinistia
Re: Help with Sudoku function please
First of all, you don't need to bump your posts. Bumping it won't get you help any faster.

Second, you should probably align all your braces along with each other since you have a bunch of nested for loops.