Nov. 2nd, 2005

donutjay: (Default)
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.

Profile

donutjay: (Default)
donutjay

July 2008

S M T W T F S
  12345
6789101112
13141516171819
2021222324 2526
2728293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 11th, 2025 04:02 pm
Powered by Dreamwidth Studios