WWGD
Science Advisor
Homework Helper
- 7,678
- 12,345
Did you feed it the needed " Boundary Conditions" for a problem to be well-defined in the sense of having a unique solution or does it implicitly know them ( or does it stop with a message if it cannot)?collinsmark said:A couple of years ago I wrote a sudoku solver program for kicks and giggles (it was written in C#). I'm pretty proud of it (given that I wrote it just for fun). I'm not very speedy at sudoku puzzles myself, but my program is. It starts by using the same techniques that humans would use to solve sudoku puzzles. Then -- and only if it is unable to make progress -- does it fall back onto a brute-force method that involves recursion.
It can solve just about any valid puzzle I can throw at it, such as those you would find in a newspaper, in a matter of milliseconds (Edit: it also checks if the puzzle is valid and if it has one and only one unique solution). It takes just over half a second to solve Arto Inkala's puzzle, perhaps the hardest sudoku puzzle ever made.
Code:int[] testArray04 = new int[] // Hardest ever, perhaps, 21 clues Also called Arto Inkala's puzzle { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 0, 0, 0, 0, 0, 0, 7, 0, 0, 9, 0, 2, 0, 0, 0, 5, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 4, 5, 7, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 6, 8, 0, 0, 8, 5, 0, 0, 0, 1, 0, 0, 9, 0, 0, 0, 0, 4, 0, 0 };
I've been neglecting it because I still need to write a user interface for it, and user interfaces are boring.