Skip to content

Instantly share code, notes, and snippets.

@mccricardo
Created November 17, 2013 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mccricardo/7519925 to your computer and use it in GitHub Desktop.
Save mccricardo/7519925 to your computer and use it in GitHub Desktop.
Naive string search
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