Created
August 25, 2017 18:10
-
-
Save kubicek/d1f4a0ba36661dd1146d1b2382fb82a5 to your computer and use it in GitHub Desktop.
railsgrills
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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