-
-
Save samueljoli/6a283e174fb1130c9f7c to your computer and use it in GitHub Desktop.
This file contains 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
sentence = <<-something | |
Steven likes the movies. Blake likes to ride his bike but hates movies. | |
Blake is taller than steven. Steven is a great teacher. | |
something | |
sentence2 = sentence.gsub('.', '').split(' ') | |
sentence2 = sentence2.collect { |i| i = i.upcase } | |
num = 1 | |
word = nil | |
count = 0 | |
counter = 0 | |
most_word = nil | |
sentence2.each do |i| | |
count = 0 | |
word = i | |
count += 1 | |
while num < sentence2.length | |
if sentence2[num] == word | |
count += 1 | |
end | |
num += 1 | |
end | |
if count > counter | |
counter = count | |
most_word = word | |
end | |
end | |
most_word | |
counter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment