Created
October 1, 2018 11:33
-
-
Save harrisonmalone/d00017bf59ee7cb0b8e22b9160f61883 to your computer and use it in GitHub Desktop.
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_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