Skip to content

Instantly share code, notes, and snippets.

Created October 29, 2014 08:44
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 anonymous/88614eca6b7e9e96cfba to your computer and use it in GitHub Desktop.
Save anonymous/88614eca6b7e9e96cfba to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# encoding: utf-8
def er_search(l, t, i=0):
mid = len(l) / 2
if l[mid] == t:
return mid + i
elif len(l) == 1:
return None
return er_search(l[:mid], t, i=i) if l[mid] > t else er_search(l[mid: ], t, i=i+mid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment