Skip to content

Instantly share code, notes, and snippets.

@Hydrotoast
Created November 2, 2013 07:03
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 Hydrotoast/7276389 to your computer and use it in GitHub Desktop.
Save Hydrotoast/7276389 to your computer and use it in GitHub Desktop.
def search(s, list):
mid = len(list) // 2
while mid >= 0 and list[mid] == None:
mid -= 1
if mid == -1:
raise Exception('No such element')
if s == list[i]:
return i
elif s < list[i]:
return search(s, list[:i])
elif s > list[i]:
return search(s, list[i:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment