Hi,

Could anyone post a working solution for the interactive problem using python? 
I just can't seem to get it to work, and when I use the testing script, the 
script just seems to stop and gives no output (and I can't seem to 
break/keyboard interrupt out of it)

My code is attached below:

import sys

def function(a,b,n):
    for _ in range(n):
        guess = (1+a+b)/2
        sys.stdout.write(str(guess)+'\n')
        sys.stdout.flush()
        response = sys.stdin.readline().strip()
        if response == 'TOO_SMALL':
            a = guess
        elif response == 'TOO_BIG':
            b = guess - 1
        else:
            return

cases = int(sys.stdin.readline())
for case in range(cases):
    a,b = [int(n) for n in sys.stdin.readline().split()]
    n = int(sys.stdin.readline())
    function(a,b,n)
    
    

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/dcd7d67a-24f3-4b5a-8110-3633989bb437%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to