![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
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.
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.
no subject
Date: 2005-11-03 04:35 am (UTC)"That conversation" was the one where we were "discussing" the fact that
no subject
Date: 2005-11-03 03:06 pm (UTC)no subject
Date: 2005-11-03 03:39 pm (UTC)My officemate is also talking about writing a program to solve Sudoku puzzles. I think it's a programmer thing.
no subject
Date: 2005-11-03 06:02 pm (UTC)