Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions archive/r/ruby/longest-word.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
input_str = ARGV.join(" ").strip

if input_str.empty?
puts "Usage: please provide a string"
exit
end

words = input_str.split
max_length = 0

words.each do |word|
if word.length > max_length
max_length = word.length
end
end

puts max_length