Here is the error:
> Traceback (most recent call last):
> File "main.py", line 19, in <module>
> moyr = sum(mat[i]) / len([y for y in mat[i] if y != 0])
> ZeroDivisionError: division by zero
On Tuesday, 14 April 2020 02:08:42 UTC+10, thierry njike wrote:
>
> Hello,
>
> My code works locally and test completed son the judge
>
> but i got Runtime Error on the judge, what's wrong with it please? My code
> bellow
>
>
> t = int(input())
>
> for ii in range(t):
> r, c = list(map(int, input().split()))
> mat = []
>
> for jj in range(r):
> mat.append(list(map(int, input().split())))
>
> value = 0
> nex = [0]
>
> while (len(nex) != 0):
> nex = []
>
> for i in range(r):
> value += sum(mat[i])
> tempr = mat[i]
> moyr = sum(mat[i]) / len([y for y in mat[i] if y != 0])
>
> for j in range(c):
>
> if mat[i][j] != 0:
> tempc = [x[j] for x in mat]
> moyc = sum(tempc) / len([y for y in tempc if y != 0])
>
> if mat[i][j] < moyc or mat[i][j] < moyr:
>
> if sum([tempc[x] for x in range(r) if x != i]) != 0
> or sum([tempr[x] for x in range(c) if x != j]) != 0:
> nex.append([i, j])
>
> for k in nex:
> mat[k[0]][k[1]] = 0
>
> print('Case #{}: {}'.format(ii + 1, value))
>
>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/57784160-1cf3-4151-8783-a38f4e84d0ea%40googlegroups.com.