Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/code-snippet-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ assignees: ''

To request a new code snippet, please fill out the following:

Project name:
Project link: https://sampleprograms.io/projects/my-project-name
Language:
Project name: longest-word.rb
Project link: https://sampleprograms.io/projects/longest-word/
Language: Ruby

If this code snippet will also be the first in a new language, please fill out the following:

Expand Down
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