From: Adam Shelly Date: 2006-07-16T06:34:07+09:00 Subject: Re: Who likes Sudoku? On 7/15/06, Adam Shelly 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; } p "Solution: #{$p}" end; $p = $*[0].split('').map{|v|v.to_i}; s