From 1af297d7c304f327cb89e08f28222236fc9b03fb Mon Sep 17 00:00:00 2001 From: Evan McCullough Date: Fri, 24 May 2019 11:20:03 -0400 Subject: [PATCH 1/2] Evan McCullough's solutions to the MoreEnumerables Challenge --- challenge.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/challenge.rb b/challenge.rb index 0585882..2580363 100644 --- a/challenge.rb +++ b/challenge.rb @@ -1,26 +1,26 @@ def capitalize_each_string(input) - #implement your solution here + input.map(&:capitalize) end def fetch_the_dog(input) - #implement your solution here + input.select { |i| i == 'dog' } end def no_dogs_allowed(input) - #implement your solution here + input.reject { |i| i == 'dog' } end def count_the_animals(input) - #implement your solution here + input.count end def fetch_the_first_two(input) - #implement your solution here + input.first(2) end def fetch_CD_animals(input) - #implement your solution here + input.select.grep(/^[cd]/) end ## DO NOT CHANGE CODE BELOW THIS LINE ## @@ -29,7 +29,7 @@ def fetch_CD_animals(input) p capitalize_each_string(animals) == ["Cat", "Moose", "Dog", "Bird"] -p fetch_the_dog(animals) == ["dog"] +p fetch_the_dog(animals) == ["dog"] p no_dogs_allowed(animals) == ["cat", "moose", "bird"] From 34d8c14035220003acb96f678a121732a829635c Mon Sep 17 00:00:00 2001 From: Evan McCullough Date: Fri, 24 May 2019 11:23:42 -0400 Subject: [PATCH 2/2] Fixed to remove unnecessary .select with grep --- challenge.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge.rb b/challenge.rb index 2580363..078f88a 100644 --- a/challenge.rb +++ b/challenge.rb @@ -20,7 +20,7 @@ def fetch_the_first_two(input) end def fetch_CD_animals(input) - input.select.grep(/^[cd]/) + input.grep(/^[cd]/) end ## DO NOT CHANGE CODE BELOW THIS LINE ##