Created
February 5, 2015 01:00
-
-
Save netmask/4ab0b27149fce50100fa 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 anagrams() | |
anagrams = {} | |
words = [] | |
['CASA', 'SACA', 'AMACA'].each do |word| | |
anagrams[word] = word.chars.sort | |
end | |
anagrams.each do |word, anagram| | |
anagrams.each do |compare_word, compare_anagram| | |
words << word if anagram == compare_anagram && word != compare_word | |
end | |
end | |
words | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment