From 8982ef7fa5484324359fdd5cf89f1a1ccd90df9a Mon Sep 17 00:00:00 2001 From: Kent Richard Date: Wed, 5 Jul 2017 23:25:30 +0000 Subject: [PATCH 1/3] I think I solved the first part --- app/controllers/calculations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 0df2d0f..d087423 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -11,7 +11,7 @@ def word_count # ================================================================================ - @word_count = "Replace this string with your answer." + @word_count = @text.split.count @character_count_with_spaces = "Replace this string with your answer." From 5372a0538e139e6b4e55797e167424a0fea25496 Mon Sep 17 00:00:00 2001 From: Kent Richard Date: Wed, 5 Jul 2017 23:41:42 +0000 Subject: [PATCH 2/3] Solved count with spaces --- app/controllers/calculations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index d087423..c6cdaa4 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -13,7 +13,7 @@ def word_count @word_count = @text.split.count - @character_count_with_spaces = "Replace this string with your answer." + @character_count_with_spaces = @text.length @character_count_without_spaces = "Replace this string with your answer." From eead4e8cde0e87b976c9ecfd590e8b5432b5d745 Mon Sep 17 00:00:00 2001 From: Kent Richard Date: Thu, 6 Jul 2017 00:06:45 +0000 Subject: [PATCH 3/3] Solved count without spaces --- app/controllers/calculations_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index c6cdaa4..499c8fb 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -15,9 +15,9 @@ def word_count @character_count_with_spaces = @text.length - @character_count_without_spaces = "Replace this string with your answer." + @character_count_without_spaces = @text.gsub(/\s+/, "").length - @occurrences = "Replace this string with your answer." + @occurrences = @text.count(@special_word) # ================================================================================ # Your code goes above.