Created
March 21, 2013 03:53
-
-
Save kayline/5210561 to your computer and use it in GitHub Desktop.
Reverse words. Seems to work but the Rspec fails
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
def reverse_words(str) | |
array = [] | |
result = "" | |
str.each_line(" ") { |s| array.push(s.reverse)} | |
array.each do |i| | |
result = result + i +" " | |
end | |
result = result.chop.lstrip | |
puts result | |
return result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment