donutjay: (Default)
[personal profile] donutjay
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.
From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

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 Sep. 19th, 2017 04:53 pm
Powered by Dreamwidth Studios