Skip to content

Instantly share code, notes, and snippets.

@nyx-rattapoom
Created March 30, 2018 20:08
Show Gist options
  • Save nyx-rattapoom/812cedb1f61dfb553803c53563a776cd to your computer and use it in GitHub Desktop.
Save nyx-rattapoom/812cedb1f61dfb553803c53563a776cd to your computer and use it in GitHub Desktop.
import sys
TOO_BIG = 'TOO_BIG'
CORRECT = 'CORRECT'
TOO_SMALL = 'TOO_SMALL'
WRONG_ANSWER = 'WRONG_ANSWER'
def main():
tc = int(input())
while tc:
tc -= 1
a, b = map(int, input().split())
number_list = [x for x in range(a+1, b+1)]
low = 0
hi = len(number_list)
n = int(input())
for i in range(n):
mid = (low + hi) // 2
print(number_list[mid])
sys.stdout.flush()
response = input()
if response == WRONG_ANSWER:
sys.exit(0)
elif response == CORRECT:
break
elif response == TOO_BIG:
hi = mid - 1
elif response == TOO_SMALL:
low = mid + 1
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment