Skip to content

Instantly share code, notes, and snippets.

@arn-e
Created October 29, 2012 00:41
Show Gist options
  • Select an option

  • Save arn-e/3970715 to your computer and use it in GitHub Desktop.

Select an option

Save arn-e/3970715 to your computer and use it in GitHub Desktop.
binary_search_abridged
def bs(i,a,m=0,x=a.size,h=(m+x)/2,l=a.size)
i==a[m]?m:(i<a[0]||i>a[l-1])||m==x-1?-1:i<a[h]?bs(i,a,m,h):bs(i,a,h,l)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment