Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BackTracking Recursive Help

Status
Not open for further replies.

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. For some reason it is just extremely hard for me to follow the 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top