Nov 02, 2005 22:29
So, I finally finished my Sudoko solver. I tried valiently to write it in Perl, but recursion, pointers, and strangely scoped variable defeated me. I spent an hour converting it to Java, and now it solves any puzzle I throw at it in less than a second (except for that one weird one that took 44 seconds).
It's pretty dumb. It guesses a number, fills in as many squares as possible, and then guesses another number until it either reaches an impossible configuration and backtracks, or solves it. There are some Sudoko solvers out there on the web that don't use guessing at all, but I was trying to keep mine simple.
I was really surprised at the speed. I figured with all the recursion and brute force, it would take a while, but even on the last puzzle in my Sudoko book, it finishes it in like half a second.
If anybody wants to look at the code, let me know.
geek