Guest User

Untitled

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