Created
December 30, 2016 18:20
-
-
Save anonymous/421b787391208fbc6bc4793b6a608796 to your computer and use it in GitHub Desktop.
This file contains 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
def anagram | |
word_groups = self.chars.permutation.map(&:join).uniq.group_by(&:chr) | |
word_groups.map do |letter, words| | |
$search_dictionary[letter] & words | |
end.flatten.compact - [self] | |
keys = [] | |
word_groups.each {|key, value| keys.push(key)} | |
y = keys.length | |
y.times do |n| | |
p word_groups[keys[n]] & $search_dictionary[keys[n]] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment