Skip to content

Instantly share code, notes, and snippets.

@lwhsu
Last active October 24, 2020 06:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lwhsu/3c44a84cb1ec9315d195f9e98e006059 to your computer and use it in GitHub Desktop.
Save lwhsu/3c44a84cb1ec9315d195f9e98e006059 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
f = open('revisions')
revisions = [x.rstrip('\n') for x in f.readlines()]
low = 0
high = len(revisions) - 1
ptr = 0
while low < high:
print("=====================")
print("low: {}".format(low))
print("high: {}".format(high))
ptr = (low + high) // 2
print("ptr: (low + high) / 2 = {}".format(ptr))
cmd = "./check.sh {}".format(revisions[ptr])
if os.system(cmd) == 0:
low = ptr + 1
else:
high = ptr
print("======= Final: =======")
print("low: {} (ans)".format(low))
print("high: {}".format(high))
print("ptr: {}".format(ptr))
print("revision: {}".format(revisions[low]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment