[QUIZ] Sodoku Solver (#43)

solutions. The value of this optimization appears to be a wash; most
boards I clock under your time by 20-50%, but on the "hard board" you
clock a 20s against my "more efficient" 37s. Wild. Something about
that puzzle forces any solver to grind deep and hard, and your not
taking extra time to think about the next move pays off handsomely.

Interesting... thanks... :slight_smile:

Your calculate_options method seems to do what my settle method does,
finding unsolved cells with only one option. One question I had while
reading your code, what happens if your loop finds a cell with options,
then finds a cell to settle, and settling it causes the other cell to no
longer have options (but to be settled)? have_options is never reset.

I initially wanted to use have_options within brute_force, basically
to tell me that the current iteration is a dead end. But then I found
an easier way out, and left it at that.

···

--
Mohit Muthanna [mohit (at) muthanna (uhuh) com]
"There are 10 types of people. Those who understand binary, and those
who don't."

Gavin Kistner wrote:

line.delete!("+-| ")

Oooh, I didn't know/forgot about that method. Nice :slight_smile:

These are all new to me. I learned Ruby by skimming the manual for the syntax needed to express my C++ thinking in Ruby. :slight_smile:

When I discovered gsub! took a regex, I went back and reread some of the String documentation. I was going to use

line.squeeze ' '

But line.delete is more clear. I'll probably still use gsub! before it, because to my thinking the proper behavior is to throw away all characters that aren't digits. Dono... we're into "proper parsing of invalid input" at this point. I only squeeze the whitespace because I was using split() to break up the input. That may be unecessary (split /\s+/) or avoidable (remove all whitespace, iterate over chars).

James, I'll edit the code, because these are nice changes. I hate to spam the list, but I'm assuming that reposting is the preferred way to update code for the Quiz, since you simply reference the web archive of the post directly?

-dB

···

On Aug 24, 2005, at 7:36 AM, James Edward Gray II wrote:

--
David Brady
ruby_talk@shinybit.com
I'm feeling really surreal today... OR AM I?

Sure, feel free to repost. However, I've already edited that method in the summary. :wink:

James Edward Gray II

···

On Aug 24, 2005, at 11:26 AM, David Brady wrote:

James, I'll edit the code, because these are nice changes. I hate to spam the list, but I'm assuming that reposting is the preferred way to update code for the Quiz, since you simply reference the web archive of the post directly?