Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'enumerator';V,G,W=File.read("w").split,[],[];$stdin.read.scan(/ (\w) /
- ).flatten.each_slice(4){|s|G<<s};def d(z);c,ct=z[-1],[];(-1..1).each{|i|(-1..
- 1).each{|j|nc=[c[0]+i,c[1]+j];unless nc.min<0 or nc.max>3 or z.include?nc;ct.
- push z.clone<<[c.first+i,c.last+j];end}};return ct;end;def s(z,wl);r=z.map{|i,
- j| G[i][j]}.to_s;g=/^#{r}/;unless (wl=wl.select{|w|w=~g}).empty?;if(r.size>3\
- and wl.include?r);W<<r;end;d(z).each{|w|s w,wl}end;end;(0..3).each{|i|(0..3).
- each{|j| s([[i,j]], V.clone)}};W.uniq!;puts "Found #{W.size} words:";puts W
Add Comment
Please, Sign In to add comment