

For example, consider the scenario shown below. The coordinates of Euclid, Pascal, and Monte have been shown in the figure.
Euclid and Monte are standing at the endpoints of a diagonal and Pascal is standing at one vertex of the other diagonal. Using the coordinates of Pascal, Euclid and Monte, figure out the coordinates of Pythagoras, which will be (10, 15).
The coordinates of Pythagoras will be unique for the unique values of the other three coordinates.
The first line of the input contains a single integer T, representing the number of test cases.
The first and only line of each test case contains six space-separated integers, x1, y1, x2, y2, x3, y3.
x1→ X coordinate of Euclid
y1→ Y coordinate of Euclid
x2→ X coordinate of Pascal
y2→ Y coordinate of Pascal
x3→ X coordinate of Monte
y3→ Y coordinate of Monte
For each test case, print two space-separated integers, denoting the values of X and Y coordinates of Pythagoras.
You do not need to print anything; it has already been taken care of. Just implement the given function.
Return a list containing two integers denoting the x and the y-coordinate of Pythagoras.
1 <= T <= 10^2
-10^9 <= x1, y1, x2, y2, x3, y3 <= 10^9
Time Limit: 1sec
Approach: We know that the diagonals of a parallelogram bisect each other. That means the point where two diagonals (AC and BD) of a parallelogram(ABCD) intersect divides AC and BD into two equal halves. See the image below for more clarity:-
In the above parallelogram, E is the point of intersection of AC and BD. Hence, E divides both Ac and BD into two equal halves. As is clear, E is the midpoint of both AC and BD. Hence, given the coordinates of A, B, and C, we can find the coordinates of D using the formula for the midpoint of a line segment joining two points.
For any two arbitrary points A(x1, y1) and B(x2, y2), the midpoint of the line segment joining AB is - {(x1+x2)/1, (y1+y2)/2}.
Using the above formula on our problem,
(Ax + Cx)/2 = (Bx + Dx)/2 and,
(Ay + Cy)/2 = (By + Dy)/2 where
A→ Euclid, B→ Pascal, C→ Monte, D→ Pythagoras.
Solving for Dx and Dy, we get the following relations:-
We can then use these relations directly to find out the coordinates of missing point D (Pythagoras in our case).