Skip to content

Instantly share code, notes, and snippets.

@khannasarthak
Last active July 5, 2017 14:54
Show Gist options
  • Save khannasarthak/711347878ee5d5e96661856facd7b0a0 to your computer and use it in GitHub Desktop.
Save khannasarthak/711347878ee5d5e96661856facd7b0a0 to your computer and use it in GitHub Desktop.
def dist(a,b):
return ((a[0]-b[0])**2 + (a[1] -b[1])**2)
t = int(input())
while (t!=0):
t -= 1
a = list(map(int,(input().split())))
# do not use split(' '), Gives rise to EOF or literal errors
k = [a[i:i+2] for i in range(0, len(a), 2)]
p1 = k[0]
p2 = k[1]
p3 = k[2]
p4 = k[3]
d1 = dist(p1,p2)
d2 = dist(p1,p3)
d3 = dist(p1,p4)
if (p1==p2==p3==p4):
print (0)
elif (d1==d2 and d2*2==d3):
if (dist(p4,p2)==dist(p4,p3)):
print (1)
elif (d2==d3 and d3*2==d1):
if (dist(p4,p2)==dist(p2,p3)):
print (1)
elif (d3==d1 and d1*2==d2):
if (dist(p4,p3)==dist(p2,p3)):
print (1)
else:
print (0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment