Sudoku Solving algorithm

caeanis

Freshman
Joined
Sep 6, 2006
Messages
40
I have a game that I've generated for an assignment. It isn't a true sudoku game in that it's only 4 regions of 4 squares instead of the nine. I have looked over some of the code that has been posted to solve the standard games and it doesn't appear that there should be anything different with mine, just less complex. The problem is this. Some of the squares are already filled in, and while the game is easy enough to solve manually, I am supposed to put a option in to hint for the correct number in a given square. This means I'm not displaying all the correct numbers for all the empty squares, just the one specified. I thought of passing the handle of that button to a variable on the click event since by clicking on a hint button it will lose focus but my real problem is I suck at math and do not in the least understand the logic behind many of the solvers therefore I don't understand how to code the solving routine to just return the value for the one specific cell or box on the grid. Any suggestions on where to look or a reference to a good article that explains the solving process would be much appreciated. I've downloaded a few sample project and tried to modify them to try to just get the one value I'm looking for but haven't got far yet as I don't understand the logic well enough to know what to change.

Caeanis
 
I have no solutions for you...

However, I think that a related question is: how do you guarantee that there is a single, unique solution? That is, the starting position for your board should fill in enough squares so that there is only one possible solution without filling in too many, or else the problem will be to easily solved.

If the starting position does not guarantee a single, unique solution, then your "hint" functionality becomes much more complicated! I suppose that your hint could show any one of several valid values, or perhaps show them all? Ideally, however, you're starting board should only allow for one possible solution... If that is the case, then your hint functionality will be easier to implement.

Unfortunately my thoughts here are not of much help! You need some sort of solution algorithm, and that same algorithm would be used to determine if there is only one unique solution, as well as be used for your hint functionality...

(I hope this helps in some small way? Probably not...)
 
You could start with something as simple as going through all the rows and columns that have already have three numbers in them. Obviously the last number will be the one not already present on the row.


PS: Also you might want to check if the given starting sudoku is solvable at all.
 
Back
Top