1. You are sending extra blank lines. Remove the appended newline in
getresponse()
2. You are formatting the result as a floating point number, e.g. "2.0".
Format it as an integer.

On Sat, Apr 13, 2019 at 10:54 PM Waffle 3z <[email protected]> wrote:

> Fixed that and tried a bit more. The only way I can try to debug this is
> to see what causes a TLE error and what causes a RE error. If an assertion
> fails then it's a RE error. It seems to be responding with -1 when I output
> the 18 numbers on a line for the windmill blade counts. I don't know what
> it wants.
>
> local function inv(a, b)
>         local m, c, d = b, 1, 0
>         while b ~= 1 do
>                 a, b, c, d = b%a, a, d - c*math.floor(b/a), c
>         end
>         return d%m
> end
>
> function remainder(m, b)
>         local M = 1
>         for i = 1, #m do M = M*m[i] end
>         local x, Mi = 0
>         for i = 1, #m do
>                 Mi = M/m[i]
>                 x = x + b[i]*inv(Mi, m[i])*Mi
>         end
>         return x%M
> end
>
> local function getresponse(input)
>         print(input.."\n")
>         io.flush()
>         return io.read()
> end
>
> local T = tonumber(io.read():match("%d+"))
> for _ = 1, T do
>         local n = {7, 11, 13, 15, 16, 17}
>         local a = {}
>         for i = 1, #n do
>                 local result = getresponse((n[i].." "):rep(18):sub(1, -2))
>                 local count, values = 0, 0
>                 for v in result:gmatch("%d+") do
>                         count = count + v
>                         values = values + 1
>                 end
>                 assert(values == 18)
>                 a[i] = count%n[i]
>         end
>         local gophers = remainder(n, a)
>         local verdict = getresponse(gophers)
>         assert(verdict == "1")
> end
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/62d346f8-94af-478d-9580-1d8791b1af46%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAE-ZSdKyQZDcwNeHTEMmHUUM52Bhn3%2Bqgpx1bwY-R4vHYLAieA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to