------ art_51490_1092897.1153006710317
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Cut down, and formatted:
def s;h ;81.times{|j|next if$p[j]>0;80.times{|k|h[
$p[k]]if k/9 /9||k%9 %9||k/27 /27&&k%9/3 %
9/3};1.upto(9){|v|($p[j] s)if !h[v]};return$p[j]
p "Solution:#$p"end;$p [0].split(//).map{|v|v.to_i};s
:)
j`ey
http://www.eachmapinject.com
On 7/15/06, Adam Shelly <adam.shelly / gmail.com> 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]] if k/9 /9 || k%9 %9 || k/27 /27
> && k%9/3 %9/3}
> 1.upto(9){|v| $p[j] and s unless h[v]}
> return $p[j] }
> p "Solution: #{$p}"
> end;
> $p *[0].split('').map{|v|v.to_i}; s
>
>
------ art_51490_1092897.1153006710317--