From a9819b9065524a7e0de7e9ddb42cf957192ba2cd Mon Sep 17 00:00:00 2001 From: Leah Musie Date: Thu, 12 Jan 2017 16:01:20 -0500 Subject: [PATCH 1/2] completed activity --- anagram_detector.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anagram_detector.rb b/anagram_detector.rb index f67e128..c4e678b 100644 --- a/anagram_detector.rb +++ b/anagram_detector.rb @@ -1,5 +1,7 @@ # Implement this in such a way that when called below, detect_anagram will result in true or false. def canonical(word) + word.downcase! + word.split("").sort_by{|char| char} end def detect_anagram(word1, word2) @@ -12,5 +14,3 @@ def detect_anagram(word1, word2) p detect_anagram('pants', 'pants') == true p detect_anagram('CinEmA', 'iceman') == true p detect_anagram('defgh8', 'g8hefd') == true - - From a490d3911c10ee9450f094cdcfdf59118c44d4c0 Mon Sep 17 00:00:00 2001 From: Leah Musie Date: Mon, 23 Jan 2017 09:43:38 -0500 Subject: [PATCH 2/2] removed mutation --- anagram_detector.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anagram_detector.rb b/anagram_detector.rb index c4e678b..db4a547 100644 --- a/anagram_detector.rb +++ b/anagram_detector.rb @@ -1,7 +1,7 @@ # Implement this in such a way that when called below, detect_anagram will result in true or false. def canonical(word) - word.downcase! - word.split("").sort_by{|char| char} + down = word.downcase + canon = down.split("").sort_by{|char| char} end def detect_anagram(word1, word2)