From: "Marcin Mielżyński" Date: 2006-07-16T04:45:12+09:00 Subject: Re: Who likes Sudoku? studlee2@gmail.com wrote: > Smaller still. Thanks David/Daniel: > > $p = ARGV.shift.split(//) > > def s > h=Hash.new() > 80.times do |j| > next if $p[j].to_i!=0 > > 80.times{|k|h[k.to_i/9==j/9||k.to_i%9==j%9||k.to_i/27==j/27&&k.to_i%9/3==j%9/3?$p[k.to_i]:0]=1} > 1.upto(9){|v|next if h.has_key?(v.to_s);$p[j]=v.to_s;s} > return $p[j]=0; > end > return (puts "\nSolution:#{$p}") > end > > s > Other cosmetic suggestions: change: ARGV to $* h=Hash.new to h={} next if $p[j].to_i!=0 to $p[j].to_i!=0&&next all do..end to {..} get rid of new lines ;) lopex