Created
October 26, 2011 17:48
-
-
Save DonSchado/1317131 to your computer and use it in GitHub Desktop.
Given a sentence containing multiple words, find the frequency of a given word in that sentence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_frequency(sentence, word) | |
sentence.downcase.split.count(word.downcase) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment