Le dimanche 1 avril 2018 10:10:46 UTC+2, Xiongqi ZHANG a écrit :
> Would you share your python solution? Maybe we can take a look.

Here mine, .. keep having "Runtime Error"

import sys

def guess_nb(a, b):
    if a > b:
        buff = a
        a = b
        b = buff
    guessnb = int((b - a) / 2) + a
    return int(guessnb)

print("Starting\n", flush=True,file=sys.stderr)
T = int(sys.stdin.readline())
while T > 0:

    line = sys.stdin.readline()
    A, B = line.rsplit()
    A = int(A)
    B = int(B)
    N = int(sys.stdin.readline())
    while N:
        print(f"A={A} B={B} N={N}", flush=True, file=sys.stderr)
        nb = guess_nb(A, B)
        print(nb, flush=True)
        print(nb, flush=True, file=sys.stderr)
        rep = sys.stdin.readline().rstrip()
        print("["+rep+"]", flush=True, file=sys.stderr)
        if rep == "TOO_SMALL":
            A = nb
            N -= 1
        elif rep == "TOO_BIG":
            B = nb
            N -= 1
        elif rep == "CORRECT":
        elif rep == "WRONG_ANSWER":
            N = 0
            print("Error rep not found", flush=True, file=sys.stderr)
    T -= 1

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 
For more options, visit https://groups.google.com/d/optout.

Reply via email to