Skip to content

Instantly share code, notes, and snippets.

@olologin
Created November 8, 2015 20:10
Show Gist options
  • Save olologin/30617c23d17361fbe770 to your computer and use it in GitHub Desktop.
Save olologin/30617c23d17361fbe770 to your computer and use it in GitHub Desktop.
low = 0
high = 100
print("Please think of a number between 0 and 100")
while True:
guess = low + int((high-low)/2)
print("Is it #{0}?".format(guess))
answer = input("Enter 'h', 'l, 'c' :")
if answer is 'h':
if high - low == 1:
guess = low
high = guess
elif answer is 'l':
if high - low == 1:
guess = high
low = guess
elif answer is 'c':
print("Nice!")
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment