Created
August 28, 2014 02:29
-
-
Save bernEsp/fb55e07180788b568b4c to your computer and use it in GitHub Desktop.
write a function that receives two list of strings and compare strings in the same index if they are anagram
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(first_word, second_word) | |
anagrams = [] | |
first_word.each_with_index do |element, index| | |
anagrams << {"#{element.downcase}" => "#{second_word[index].downcase}" } if element.downcase.sum == second_word[index].downcase.sum | |
end | |
anagrams | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment