Skip to content

Instantly share code, notes, and snippets.

@shosanna
Created June 14, 2014 22:19
Show Gist options
  • Save shosanna/0761d9b235ab39105759 to your computer and use it in GitHub Desktop.
Save shosanna/0761d9b235ab39105759 to your computer and use it in GitHub Desktop.
function naïve_string_search(kupka, jehla) {
for i ← 0 upto (kupka.length - jehla.length) {
j ← 0
while (j < jehla.length && kupka[i + j] == jehla[j]) j += 1
if j == jehla.length return i
}
return -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment