Given three coordinate points A, B and C, find the missing point D such that ABCD can be a parallelogram. If there are multiple such points, find the lexicographically smallest coordinate.
Example 1:
Input:
A = (3, 2)
B = (3, 4)
c = (2, 2)
Output:
2.000000 0.000000
Explanation: There are two options for 
point D : (2, 4) and (2, 0) such that ABCD 
forms a parallelogram. Since (2, 0) is 
lexicographically smaller than (2, 4). Hence,
(2, 0) is the answer.
Your Task:
You don't need to read input or print anything. Your task is to complete the function findPoint() which takes three list of integers A[], B[] and C[] and return D[] list of two numbers with a precision of 6 decimal places where first element of D[ ] denote x coordinate and second element of D[ ] denote y coordinate.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ x, y ≤ 1000 , where x and y denote coordinates of points A, B and C.

Difficulty: MEDIUM
Tags: Geometry

Mathematics
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def findPoint(self, A, B, C):
        # code here

Solutions:
class Solution:

	def findPoint(self, A, B, C):
		d1 = [B[0] + C[0] - A[0], B[1] + C[1] - A[1]]
		d2 = [A[0] + C[0] - B[0], A[1] + C[1] - B[1]]
		d3 = [A[0] + B[0] - C[0], A[1] + B[1] - C[1]]
		return min(d1, d2, d3)


class Solution:

	def findPoint(self, A, B, C):
		x = [A[0] + B[0] - C[0], A[1] + B[1] - C[1]]
		y = [A[0] - B[0] + C[0], A[1] - B[1] + C[1]]
		z = [-A[0] + B[0] + C[0], -A[1] + B[1] + C[1]]
		return min(x, y, z)


class Solution:

	def find(self, A, B, C):
		if A[0] < B[0]:
			if A[0] < C[0]:
				return A
			elif A[0] <= C[0]:
				if A[1] < C[1]:
					return A
				else:
					return C
			else:
				return C
		elif A[0] > B[0]:
			if B[0] < C[0]:
				return B
			elif B[0] <= C[0]:
				if B[1] < C[1]:
					return B
				else:
					return C
			else:
				return C
		elif C[0] < A[0]:
			return C
		elif A[1] < B[1]:
			return A
		else:
			return B

	def findPoint(self, A, B, C):
		p1 = [A[0] + B[0] - C[0], A[1] + B[1] - C[1]]
		p2 = [A[0] + C[0] - B[0], A[1] + C[1] - B[1]]
		p3 = [C[0] + B[0] - A[0], C[1] + B[1] - A[1]]
		res = self.find(p1, p2, p3)
		return res
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		A = []
		B = []
		C = []
		input1 = [int(x) for x in input().strip().split(' ')]
		A.append(input1[0])
		A.append(input1[1])
		input2 = [int(x) for x in input().strip().split(' ')]
		B.append(input2[0])
		B.append(input2[1])
		input3 = [int(x) for x in input().strip().split(' ')]
		C.append(input3[0])
		C.append(input3[1])
		ob = Solution()
		ans = ob.findPoint(A, B, C)
		print('{:.6f}'.format(ans[0]), '{:.6f}'.format(ans[1]))


import math

class Solution:

	def findPoints(self, source, m, l):
		a = [0] * 2
		b = [0] * 2
		if m == 0:
			a[0] = source[0] + l
			a[1] = source[1]
			b[0] = source[0] - l
			b[1] = source[1]
		elif m == float('inf'):
			a[0] = source[0]
			a[1] = source[1] + l
			b[0] = source[0]
			b[1] = source[1] - l
		else:
			dx = l / math.sqrt(1 + m * m)
			dy = m * dx
			a[0] = source[0] + dx
			a[1] = source[1] + dy
			b[0] = source[0] - dx
			b[1] = source[1] - dy
		return [a, b]

	def findSlope(self, p, q):
		if p[1] == q[1]:
			return 0
		if p[0] == q[0]:
			return float('inf')
		return (q[1] - p[1]) / (q[0] - p[0])

	def findDistance(self, p, q):
		return math.sqrt(math.pow(q[0] - p[0], 2) + pow(q[1] - p[1], 2))

	def findMissingPoint(self, a, b, c):
		ans = [0] * 2
		d = self.findPoints(a, self.findSlope(b, c), self.findDistance(b, c))
		if self.findDistance(d[0], c) == self.findDistance(a, b):
			ans[0] = d[0][0]
			ans[1] = d[0][1]
		else:
			ans[0] = d[1][0]
			ans[1] = d[1][1]
		return ans

	def findPoint(self, A, B, C):
		ans = []
		ans.append(self.findMissingPoint(A, B, C))
		ans.append(self.findMissingPoint(B, A, C))
		ans.append(self.findMissingPoint(B, C, A))
		ans.sort()
		return ans[0]


class Solution:

	def findPoint(self, A, B, C):
		x = []
		x1 = (A[0] * 2 - B[0] + (C[0] * 2 - B[0])) / 2.0
		y1 = (A[1] * 2 - B[1] + (C[1] * 2 - B[1])) / 2.0
		x2 = (B[0] * 2 - A[0] + (C[0] * 2 - A[0])) / 2.0
		y2 = (B[1] * 2 - A[1] + (C[1] * 2 - A[1])) / 2.0
		x3 = (A[0] * 2 - C[0] + (B[0] * 2 - C[0])) / 2.0
		y3 = (A[1] * 2 - C[1] + (B[1] * 2 - C[1])) / 2.0
		x.append((x1, y1))
		x.append((x2, y2))
		x.append((x3, y3))
		x = sorted(x)
		return x[0]


class Solution:

	def findPoint(self, A, B, C):
		x0 = A[0] - B[0] + C[0]
		y0 = A[1] - B[-1] + C[1]
		x1 = A[0] + B[0] - C[0]
		y1 = A[1] + B[-1] - C[1]
		x2 = B[0] + C[0] - A[0]
		y2 = B[-1] + C[1] - A[1]
		pairs = [[x0, y0], [x1, y1], [x2, y2]]
		pairs.sort()
		return pairs[0]


class Solution:

	def findPoint(self, A, B, C):
		x1 = A[0] + C[0] - B[0]
		y1 = A[1] + C[1] - B[1]
		x2 = A[0] + B[0] - C[0]
		y2 = A[1] + B[1] - C[1]
		x3 = B[0] + C[0] - A[0]
		y3 = B[1] + C[1] - A[1]
		l = []
		l.append((x1, y1))
		l.append((x2, y2))
		l.append((x3, y3))
		l.sort()
		return l[0]


class Solution:

	def findPoint(self, A, B, C):
		return min((A[0] + C[0] - B[0], A[1] + C[1] - B[1]), (B[0] + A[0] - C[0], B[1] + A[1] - C[1]), (C[0] + B[0] - A[0], C[1] + B[1] - A[1]))


class Solution:

	def findPoint(self, A, B, C):
		p1 = (A[0] + B[0] - C[0], A[1] + B[1] - C[1])
		p2 = (A[0] + C[0] - B[0], A[1] + C[1] - B[1])
		p3 = (B[0] + C[0] - A[0], B[1] + C[1] - A[1])
		return min(p3, min(p1, p2))


class Solution:

	def findPoint(self, A, B, C):
		point1 = (A[0] + B[0] - C[0], A[1] + B[1] - C[1])
		point2 = (A[0] + C[0] - B[0], A[1] + C[1] - B[1])
		point3 = (C[0] + B[0] - A[0], C[1] + B[1] - A[1])
		return min(point3, min(point1, point2))