[ create a new paste ] login | about

Link: http://codepad.org/9ybKILvX    [ raw code | fork ]

Python, pasted on Feb 10:
1
2
3
4
5
6
7
8
9
10
11
12
13
maxim, floor = int(raw_input('Pick a positive integer. Enter a max value now: ')),0
ceil = maxim
while True:
    guess = (floor+ceil)/2
    choice = raw_input("Is your number (h = higher, l = lower, y = yes) than %s: " %guess)

    if choice == 'l':
        ceil = guess
    elif choice == 'h':
        floor = guess
    elif  choice == 'y':
        break
print 'Number was ',guess


Create a new paste based on this one


Comments: