Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Created October 1, 2018 11:33
Show Gist options
  • Select an option

  • Save harrisonmalone/d00017bf59ee7cb0b8e22b9160f61883 to your computer and use it in GitHub Desktop.

Select an option

Save harrisonmalone/d00017bf59ee7cb0b8e22b9160f61883 to your computer and use it in GitHub Desktop.
def find_short(s)
s = s.split(" ")
l = []
s.each do |word|
l << word.length
end
l = l.min
return l # l: length of the shortest word
end
p find_short("bitcoin take over the world maybe who knows perhaps")
# => 3
# link https://www.codewars.com/kata/shortest-word/train/ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment