Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Help with Sudoku function please

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:

```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;
}```

bump, bump

3. ## 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.