Binary search ("bisect") tool Implement the binary search algorithm as used to identify the source code revision that breaks a computer software program. Your tool should take two arguments specifying the earliest and latest numbered revision to search (both positive integers), and you have two options for making comparisons:


Execute the shell command ./test N, where N is the revision number. If the test passes (i.e. the revision is good), it will return exit code 0.
Call the function test(N), which will return true if the test passes, false otherwise.


Standard output must be the number of the first bad revision, and try to make your tool's source code as short as possible. Enjoy!
Python, 64 chars
 
This one is recursive, so will overflow the stack for really large input
01234567890123456789012345678901234567890123456789012345678901234567890
|         |         |         |         |         |         |         |
 B=lambda L,H:H&gt;L+1 and B(*[L,L/2+H/2,H][test(L/2+H/2):][:2])or H

test run
def test(n):
    print &quot;testing &quot;, n
    return n&lt;66

L,H=10,1000


B=lambda L,H:H&gt;L+1 and B(*[L,L/2+H/2,H][test(L/2+H/2):][:2])or H

print B(L,H)

outputs
testing  505
testing  257
testing  133
testing  71
testing  40
testing  55
testing  62
testing  66
testing  64
testing  65
66