Help regarding TCS Mockvita Question C

import math
C=int(input())
a=[]
b=[]
Q=0
for i in range(0,C):
x, y, v=map(int, input().split(" "))
d=math.sqrt(xx+yy)
t=d/v
a.append(t)
a.sort()
from itertools import groupby
b=[len(list(group)) for key, group in groupby(a)]
n=len(b)
for j in range(0,n):
Q=Q+((b[j]*(b[j]-1))/2)
print(int(Q))

This code gave the correct output against question C of TCS mockvita both in Spyder IDE and in the IDE provided there. It passed the public test cases, however when I tried to submit, it displayed “Wrong answer” maybe due to failure to pass some private test cases. Can anyone point out any mistake that I might have made…any kind of help would be appreciated :slight_smile:
P.S : Ignore the indentations…the original code has the correct indentations but as soon as i uploaded here, it all aligned this way.

same thing i did. i also got WA.

Do not take distance(d) as sqrt(xx + yy), ignore the sqrt and take d^2 and take velocity as v^2, because of precision issues it wasn’t working for me either. I did this and it worked.

2 Likes