Created
July 10, 2012 17:34
-
-
Save andersonvom/3084934 to your computer and use it in GitHub Desktop.
substring?
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 substring?(s1, s2) | |
a = s1.size | |
b = s2.size | |
i = 0 | |
while i <= a | |
x = i | |
j = 0 | |
while j <= b | |
return true if j == b | |
return false if x == a | |
break if s1[x] != s2[j] | |
x += 1 | |
j += 1 | |
end | |
i += 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment