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.

Date: 2005-11-03 04:35 am (UTC)
From: [identity profile]
This is where I'm going "were you there for that conversation?"

"That conversation" was the one where we were "discussing" the fact that [ profile] n3nbb was also talking about writing a program to solve them.

Date: 2005-11-03 03:06 pm (UTC)
From: [identity profile]
I don't think so... I started working on this last weekend, before we were in Pittsburgh.

Date: 2005-11-03 03:39 pm (UTC)
From: [identity profile]
No, that was later in the evening, after they'd left.

My officemate is also talking about writing a program to solve Sudoku puzzles. I think it's a programmer thing.

Date: 2005-11-03 06:02 pm (UTC)
From: [identity profile]
Count me in for wanting to see the code :)


donutjay: (Default)

July 2008

2021222324 2526

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 21st, 2017 11:01 pm
Powered by Dreamwidth Studios