Adam Shelly wrote: > On 7/15/06, Adam Shelly <adam.shelly / gmail.com> wrote: >> Yes, before we golf this further, does it even work? > > oops, my mistake. I was giving it a filename containing a puzzle on > the command line instead of the puzzle itself. It does run and > converge - but it leaves the last digit 0 unless you make the outer > loop 81.times. Here's what I've got - I mapped the input to > integers, which removed a bunch of 'to_i's. > def s; h={} > 81.times{|j| next if $p[j]>0 > 80.times {|k| h[$p[k]] = 1 if k/9==j/9 || k%9==j%9 || k/27==j/27 > && k%9/3==j%9/3} > 1.upto(9){|v| $p[j]=v and s unless h[v]} > return $p[j]=0; } There's no need for the `return' keyword, nor for the semicolon. $p[j]=0} > p "Solution: #{$p}" > end; The semicolon is unnecessary. > $p = $*[0].split('').map{|v|v.to_i}; s > Cheers, Daniel