![]() Long story short, this will track and backtrack through the puzzle finding and counting possible solutions. The key here is, given the recursive algorithm (namely the fill method), it can then backtrack through the sudoku grid to the last position that still needs an increment, increments the value and continue where it left off. The algorithm will continue like so until a solved puzzle is completed. ![]() For each value that is a valid entry based upon all the previous values, the algorithm proceeds to the next sudoku grid square to perform the same calculation. Basically, for each square it arrives at, the algorithm iterates through each of the 1-9 entries. I've written a Sudoku game in the past, so I decided to expand upon that code to write an algorithm that counts how many possible solutions there are. ![]() The easy answer would be to just look it up, but why not have some fun and try to calculate it? Of course a little math and logic beforehand would have suggested I turn tail and run from the problem, live and learn. How many possible sudoku solutions are there? Sometimes thoughts such as this end up squeezing the rest of my free time out of me. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |