# Re: [gcj] python interactive solution

```Sure! Here's my solution in Python 3:

T = int(input())
COR = 'CORRECT'
SMALL = 'TOO_SMALL'
BIG = 'TOO_BIG'```
```
for qw in range(1, T+1):
a, b = map(int, input().split())
n = int(input())
while True:
mid = (a + b + 1) // 2
print(mid, flush=True)
result = input().strip()
if result == COR:
break
elif result == SMALL:
a = mid
else:
b = mid - 1

On Fri, Apr 6, 2018 at 1:15 PM Yu Wang <parukia...@gmail.com> wrote:

> 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()
>         if response == 'TOO_SMALL':
>             a = guess
>         elif response == 'TOO_BIG':
>             b = guess - 1
>         else:
>             return
>
> for case in range(cases):
>     a,b = [int(n) for n in sys.stdin.readline().split()]
>     function(a,b,n)
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> To unsubscribe from this group and stop receiving emails from it, send an
> To view this discussion on the web visit
> .
> For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups