Skip to content

Instantly share code, notes, and snippets.

@kubicek
Created August 25, 2017 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kubicek/d1f4a0ba36661dd1146d1b2382fb82a5 to your computer and use it in GitHub Desktop.
Save kubicek/d1f4a0ba36661dd1146d1b2382fb82a5 to your computer and use it in GitHub Desktop.
railsgrills
words = %w(acer acre mongol mognol mogul zigul arec reac guliz)
letters = words.collect{|w| w.scan(/\w/).sort }
words.collect.with_index{|w,i|
positions = letters.collect.with_index{|l,i| i if l==letters[words.index(w)]}.compact
puts "#{w}: #{positions.collect{|pi| words[pi] unless i==pi}.compact.join(', ')}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment