Last active
October 24, 2020 06:06
-
-
Save lwhsu/3c44a84cb1ec9315d195f9e98e006059 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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