Created
November 8, 2015 20:10
-
-
Save olologin/30617c23d17361fbe770 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
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