Determine Pythagoras' Position for Parallelogram Formation

Euclid, Pythagoras, Pascal, and Monte decide to gather in a park. Initially, Pascal, Monte, and Euclid choose three different spots. Pythagoras, arriving later, selects a position such that when his point and the others are joined, they form a parallelogram. Specifically, the positions of Euclid and Monte will form one diagonal of this parallelogram.

Your role is to calculate Pythagoras' coordinates so the four positions create a parallelogram.

Input:

The first line provides an integer T, representing the number of test cases. For each test case, the line contains six space-separated integers: x1, y1, x2, y2, x3, y3.
  • x1, y1: Coordinates of Euclid
  • x2, y2: Coordinates of Pascal
  • x3, y3: Coordinates of Monte

Output:

Output the coordinates of Pythagoras as two space-separated integers for each test case.

Example:

Input:
T = 1
x1 = 2, y1 = 3, x2 = 4, y2 = 5, x3 = 6, y3 = 7
Output:
x = 8, y = 9
[Calculation shows how to achieve this.]

Constraints:

  • 1 <= T <= 10^2
  • -10^9 <= x1, y1, x2, y2, x3, y3 <= 10^9
  • Time Limit: 1sec

Note:

The coordinates of Pythagoras are uniquely determined by the other three coordinates.
AnswerBot
1d

Calculate Pythagoras' coordinates to form a parallelogram with Euclid, Pascal, and Monte.

  • Calculate the midpoint of the line segment between Euclid and Monte to get the coordinates of Pythagoras.

  • Use th...read more

Help your peers!
Add answer anonymously...
Wipro Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter