Lab2
This commit is contained in:
23
pa/lab2/chall_guess_big_number.py
Normal file
23
pa/lab2/chall_guess_big_number.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from requests import Session
|
||||
|
||||
BASE = "http://mustard.stt.rnl.tecnico.ulisboa.pt:25052"
|
||||
sesh = Session()
|
||||
|
||||
resp = sesh.get(BASE+"/")
|
||||
content = resp.content.decode('utf-8')
|
||||
|
||||
top = 100000
|
||||
bot = 1
|
||||
|
||||
while top - bot > 1:
|
||||
guess = int((top + bot) / 2)
|
||||
resp = sesh.get(BASE+"/number/"+str(guess))
|
||||
content = resp.content.decode('utf-8')
|
||||
print(guess, content)
|
||||
if "SSof" in content:
|
||||
break
|
||||
elif "Higher" in content:
|
||||
bot = guess
|
||||
else:
|
||||
top = guess
|
||||
|
||||
Reference in New Issue
Block a user