Created
April 17, 2015 20:44
-
-
Save bgmarx/c847a56c2cc33b5395ea to your computer and use it in GitHub Desktop.
reverse implementation
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 rev(str) | |
lp = 0 | |
rp = str.length - 1 | |
while lp < rp | |
temp = str[lp] | |
str[lp] = str[rp] | |
str[rp] = str[lp] | |
lp += 1 | |
rp -= 1 | |
end | |
str | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment