ACloseFriend
Technical User
- Feb 17, 2007
- 3
Alright I need to write a mini sudoku(6 3x2 boxes) solver. Ive tried a few approaches but I just cant seem to get it down. Could anyone offer some helpful tips please.
It is really hard for me to grasp the concept of a recursive boolean method which seems to be an approach. For some reason it is just extremely hard for me to follow the numberless math out in my head. So I have been taking a strictly int based approach:
public static int addNum(int a, int b, int x){
int i=0;
int j=0;
Board[a]=x;
while(j<b&&j<6){
if(Board[a]==Board[a][j])
return Board[a] = addNum(a, b, x+1);
j++;
}
j++;//makes sure j never equals b
while(j<6){
if(Board[a]==Board[a][j])
return Board[a] = addNum(a, b, x+1);
j++;
}
while(i<a&&i<6){
if(Board[a]==Board)
return Board[a] = addNum(a, b, x+1);
i++;
}
i++;//makes sure i never equals a
while(i<6){
if(Board[a]==Board)
return Board[a] = addNum(a, b, x+1);
i++;
}
return x;
}
Basically I have it so that it adds a number to a specific point and checks whether that number equals any other number in its row/column. But this isnt enough as it won't check the number values with boxes that theyre in. Also I dont know how I would create a backtracking portion.
Im not looking for someone to write this for me, I would just like suggestions as I am completely lost. Thanks
It is really hard for me to grasp the concept of a recursive boolean method which seems to be an approach. For some reason it is just extremely hard for me to follow the numberless math out in my head. So I have been taking a strictly int based approach:
public static int addNum(int a, int b, int x){
int i=0;
int j=0;
Board[a]=x;
while(j<b&&j<6){
if(Board[a]==Board[a][j])
return Board[a] = addNum(a, b, x+1);
j++;
}
j++;//makes sure j never equals b
while(j<6){
if(Board[a]==Board[a][j])
return Board[a] = addNum(a, b, x+1);
j++;
}
while(i<a&&i<6){
if(Board[a]==Board)
return Board[a] = addNum(a, b, x+1);
i++;
}
i++;//makes sure i never equals a
while(i<6){
if(Board[a]==Board)
return Board[a] = addNum(a, b, x+1);
i++;
}
return x;
}
Basically I have it so that it adds a number to a specific point and checks whether that number equals any other number in its row/column. But this isnt enough as it won't check the number values with boxes that theyre in. Also I dont know how I would create a backtracking portion.
Im not looking for someone to write this for me, I would just like suggestions as I am completely lost. Thanks