Skip to content

Instantly share code, notes, and snippets.

Created December 30, 2016 18:20
Show Gist options
  • Save anonymous/421b787391208fbc6bc4793b6a608796 to your computer and use it in GitHub Desktop.
Save anonymous/421b787391208fbc6bc4793b6a608796 to your computer and use it in GitHub Desktop.
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