diff --git a/anagram_detector.rb b/anagram_detector.rb index f67e128..3370aaa 100644 --- a/anagram_detector.rb +++ b/anagram_detector.rb @@ -1,8 +1,10 @@ # Implement this in such a way that when called below, detect_anagram will result in true or false. def canonical(word) + puts word.downcase.chars.sort end def detect_anagram(word1, word2) + canonical(word1) == canonical(word2) end @@ -12,5 +14,4 @@ def detect_anagram(word1, word2) p detect_anagram('pants', 'pants') == true p detect_anagram('CinEmA', 'iceman') == true p detect_anagram('defgh8', 'g8hefd') == true - - +p detect_anagram('bird', 'house') == false