Welcome, guest | Sign In | My Account | Store | Cart
def search(n, L):
    f = lambda n,L,o: len(L) and ( \
        (n == L[len(L)/2])*(len(L)/2+o) or \
        (n < L[len(L)/2] and f(n,L[:len(L)/2],o)) or \
        (n > L[len(L)/2] and f(n,L[len(L)/2+1:],o+len(L)/2+1)))

    return f(n,L,1) - 1

History

  • revision 2 (20 years ago)
  • previous revisions are not available