From: Joey Date: 2006-07-16T02:15:18+09:00 Subject: Re: Who likes Sudoku? ------=_Part_49776_8910366.1152983716145 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline $p = $*[0].split // def s h={};80.times{|j|next if $p[j]!=0;80.times {|k|h[k/9==j/9||k%9==j%9||k/27==j/27&&k%9/3==j%9/3 ?$p[k]:0]=1} 10.times{|v| next if v==0||h[v];$p[j]=v;s};return $p[j]=0} return (puts "\nSolution:#{$p}" ) end I havent looked at anything special in particular to cut it down! J`ey http://www.eachmapinject.com http://www.eachmapinject.com/treasure_chest On 7/15/06, studlee2@gmail.com wrote: > > This is a little smaller. > > $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} > 10.times {|v| next if v==0 || h.has_key?(v.to_s); $p[j] = v.to_s; > s} > return $p[j] = 0; > end > return (puts "\nSolution:#{$p}" ) > end > > s > > > ------=_Part_49776_8910366.1152983716145--