Skip to content

Instantly share code, notes, and snippets.

@jishnujayakumar
Created March 17, 2021 11:38
Show Gist options
  • Save jishnujayakumar/bc3a9e6cb92b70a442b6d493f22bd207 to your computer and use it in GitHub Desktop.
Save jishnujayakumar/bc3a9e6cb92b70a442b6d493f22bd207 to your computer and use it in GitHub Desktop.
#!/bin/python3
import os, sys, math
def reflectionComponent(pcomp, qcomp):
if pcomp > qcomp:
return qcomp - abs(qcomp - pcomp)
elif pcomp < qcomp:
return qcomp + abs(qcomp - pcomp)
else:
return qcomp
def findPoint(px, py, qx, qy):
rx = reflectionComponent(px, qx)
ry = reflectionComponent(py, qy)
return rx, ry
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input())
for n_itr in range(n):
pxPyQxQy = input().split()
px = int(pxPyQxQy[0])
py = int(pxPyQxQy[1])
qx = int(pxPyQxQy[2])
qy = int(pxPyQxQy[3])
result = findPoint(px, py, qx, qy)
fptr.write(' '.join(map(str, result)))
fptr.write('\n')
fptr.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment