def play(): low = 0 high = 999 mid = (high + 1)/2 output = secret_number.guess(mid) while output != 'correct': if output == 'too-low': low = mid else: high = mid mid = low + (high-low)/2 output = secret_number.guess(mid)
def play(): low = 0 mid = 500 high = 999 response = secret_number.guess(mid) while response != "correct": if response == "too-low": low = mid elif response == "too-high": high = mid mid = low + ((high - low) / 2) response = secret_number.guess(mid)
def play(): hig = 1000 low = 0 i = 0 while i < 10: g = secret_number.guess((hig + low) / 2) if g == "too-high": hig = (hig + low) / 2 elif g == "too-low": low = (hig + low) / 2 i = i + 1
def play(): i = 0 high = 1000 low = 0 while i < 10: x = binarySearch(low , high) s = secret_number.guess(x) if s == "too-low": low = x elif s == "too-high": high = x i = i + 1
def play(): i = 0 high = 1000 low = 0 while i < 10: x = BinarySearch(low, high) s = secret_number.guess(x) if s == 'too-low': low = x elif s == 'too-high': high = x i += 1
#!/usr/bin/env python import secret_number n = 1000 def play() i = 500 hi = 1000 low = 0 z = seret_number.guess(i) while i < n and z != "correct": if z == "too-low": low = i i = low + ((hi - low) / 2) elif z == "too-high": hi = i i = hi - ((hi - low) / 2) z = secret_number.guess(i)
def play(): i = 0 while i < n and secret_number.guess(i) != "correct": i = i + 1 return i