Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- words = File.readlines('words_alpha.txt').map do |word|
- word.strip.upcase
- end.select do |word|
- word.size == 5
- end
- neighbours = Hash.new { |h, k| h[k] = [] }
- words.each do |word|
- 5.times do |i|
- neighbours[word[...i] + "-" + word[i++1..]] << word
- end
- end
- neighbours.values.select{|v| v.size > 1}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement