

If you have cells remaining with more than one possibility, save the puzzle state, pick the cell with the fewest possibilities, pick one of the possibilities, and attempt to solve the puzzle. You can use a brute force method, which searches through each column and row, collects the possible values of each cell, then weeds out the cells with only one possibility. Which might be best? 2D might be easier to manage from the surface, but 3D Arrays would provide the "box"/"cage" number as well. Looking at my code, I got to thinking: what would be some of the possibilities for storing these solving states (i.e. I'm looking for something that's vague (so it's a challenge), but informative enough (so I'm not totally lost) to get me started. If someone could provide a step-by-step, efficient thought process for solving a Sudoku puzzle (whether by a human or computer), I would be most happy :). I want to avoid mathematical algorithms if at all possible - those would be too easy and 100% not my work.
#Sudoku puzzle solver free code#
What I'm looking for is the methodology to go about solving this sucker in the most efficient way possible (please try not to include too much code - I want to figure that part out, myself).

Of course, a sheer thought of the action should raise a red flag in every programmer's mind. Probably the easiest way to do this in a program is have a ton of for loops parse through each column and row, collect the possible values of each cell, then weed out the cells with only one possibility (whether they contain only 1 number, or they're the only cell in their row/column that contains this number) until you have a solved puzzle. Yes, I know this is nothing new and there are many questions already out there (it even has its own tag), but I'd like to create a Sudoku Solver in Java solely for the purpose of training myself to write code that is more efficient.
