bristolkr / assignments

TIY homework, mostly basic Ruby files from first week
0 stars 0 forks source link

Assignment 3-4 #15

Closed ambethia closed 9 years ago

ambethia commented 9 years ago

Week 3 - Assignment 4

Description

This assignment serves to reinforce Ruby syntax and usage of blocks and enumerable with arrays and hashes. You'll also dabble in String manipulation.

After completing this assignment, you should:

The some of the tests expect words to be lowercase, but not all of the words in the text are lower case. Some of the words also end in punctuation that should be excluded when checking for unique words, i.e. "Sam-I-am!", "Sam-I-am", and "sam-i-am" should all be considered the same word.

Here's how to normalize them:

word = "Sam-I-am!"
word.downcase.gsub(/[^a-z-]/, '') # => "sam-i-am"

We'll talk about Regular Expressions soon, that's what the /[^a-z-]/ is (it matches all characters that are not "a" through "z" or "-"). Feel free to research if you want, but this is a freebie.

Resources

bristolkr commented 9 years ago

I thought I closed this on Friday? 5 done, will try to do the bonus if time allows. https://github.com/cateia97/green_eggs_and_ham

ambethia commented 9 years ago

Looks great. Your implementation of longest_word doesn't actually look for the longest word though, you just kind of give that one response ("Sam-I-am"). Checkout max_by