Created
November 17, 2013 23:47
-
-
Save mccricardo/7519925 to your computer and use it in GitHub Desktop.
Naive string search
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 naive_search(substring, string): | |
for i in range(len(string)-len(substring)+1): | |
if string[i:i+len(substring)] == substring: | |
return i | |
return -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment