From bdcf66c670b6d9175ec9c138fc402ce26712e7d2 Mon Sep 17 00:00:00 2001 From: Aaron Dawson Date: Thu, 7 Jan 2016 16:30:37 -0500 Subject: [PATCH 1/2] passes all the tests --- .DS_Store | Bin 0 -> 6148 bytes parser.rb | 9 +++++++++ 2 files changed, 9 insertions(+) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Thu, 7 Jan 2016 22:42:52 -0500 Subject: [PATCH 2/2] this should be significantly more concise --- parser.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/parser.rb b/parser.rb index ae14e47..ab5ba2b 100644 --- a/parser.rb +++ b/parser.rb @@ -1,12 +1,5 @@ def word_in_string?(word, string) # implement with your code here - if (string.include? word) - if (string =~ /#{word}[a-zA-Z]+/ || string =~ /[a-zA-Z]+#{word}/) - return :no - else - return :yes - end - else - return :no - end + word_regex = /(#{word}[^a-zA-Z]+.*|.*[^a-zA-Z]+#{word}|^#{word}$)/ + string =~ word_regex ? :yes : :no end