"Point reflection" or "point symmetry" is a basic concept in geometry where a given point, P, at a given position relative to a mid-point, Q has a corresponding point, P1, which is the same distance from Q but in the opposite direction.

## Task

Given two points P and Q, output the symmetric point of point P about Q.
Each argument is a two-element array of integers representing the point's X and Y coordinates.  Output should be in the same format, giving the X and Y coordinates of point P1.  You do not have to validate the input.

This kata was inspired by the Hackerrank challenge [Find Point](https://www.hackerrank.com/challenges/find-point)

Source: codewars | Difficulty: EASY
Tags: Geometry

Mathematics

Starter code: def symmetric_point(p, q):
	

Solutions:
def symmetric_point(p, q):
	return [2 * q[0] - p[0], 2 * q[1] - p[1]]


symmetric_point = lambda p, q: [2 * b - a for (a, b) in zip(p, q)]


def symmetric_point(p, q):
	p1x = q[0] - p[0] + q[0]
	p1y = q[1] - p[1] + q[1]
	return [p1x, p1y]


symmetric_point = lambda p, q: [2 * q[0] - p[0], 2 * q[1] - p[1]]


def symmetric_point(p, q):
	return [a * 2 - b for (a, b) in zip(q, p)]


def symmetric_point(p, q):
	dx = q[0] - p[0]
	dy = q[1] - p[1]
	return [q[0] + dx, q[1] + dy]


def symmetric_point(p, q):
	return [2 * q[i] - p[i] for i in range(2)]


def symmetric_point(p, center):
	(px, py) = p
	(cx, cy) = center
	return [cx - (px - cx), cy - (py - cy)]


def symmetric_point(p, q):
	return [2 * q[i] - p[i] for i in range(0, len(p))]


from typing import List

def symmetric_point(p: List[int], q: List[int]) -> List[int]:
	return [2 * q[0] - p[0], 2 * q[1] - p[1]]


def symmetric_point(p, q):
	result = [p[0], q[0]]
	if p[0] > q[0]:
		result[0] = fromRightToLeft(p[0], q[0])
	else:
		result[0] = fromLeftToRight(p[0], q[0])
	if p[1] > q[1]:
		result[1] = fromUpToDown(p[1], q[1])
	else:
		result[1] = fromDownToUp(p[1], q[1])
	return result

def fromRightToLeft(p, q):
	return q - abs(p - q)

def fromLeftToRight(p, q):
	return q + abs(p - q)

def fromUpToDown(p, q):
	return q - abs(p - q)

def fromDownToUp(p, q):
	return q + abs(p - q)


from operator import sub

def symmetric_point(p, q):
	qp = list(map(sub, p, q))
	return list(map(sub, q, qp))


def symmetric_point(p, q):
	return list(map(lambda a, b: a + b, q, list(map(lambda a, b: b - a, p, q))))


symmetric_point = lambda point, ref: [2 * ref[0] - point[0], 2 * ref[1] - point[1]]


import numpy as np

def symmetric_point(p, q):
	d = list(np.add(q, np.subtract(q, p)))
	return d


def symmetric_point(p, q):
	p_1 = []
	dx = p[0] - q[0]
	dy = p[1] - q[1]
	p_1.append(q[0] - dx)
	p_1.append(q[1] - dy)
	return p_1


symmetric_point = lambda p, q: [2 * y - x for (x, y) in zip(p, q)]


symmetric_point = lambda p, q: [r + r - s for (s, r) in zip(p, q)]


def symmetric_point(p, q):
	distance = (q[0] - p[0], q[1] - p[1])
	symetric = [q[0] + distance[0], q[1] + distance[1]]
	return symetric


def symmetric_point(p, q):
	(x1, y1) = p
	(x2, y2) = q
	(x3, y3) = (x2 - x1 + x2, y2 - y1 + y2)
	return [x3, y3]


def symmetric_point(p, q):
	try:
		((a, b), (c, d)) = (p, q)
		x = c - a + c
		m = (d - b) / (c - a)
		i = b - m * a
		return [x, round(m * x + i)]
	except:
		return [0, 0]


def symmetric_point(p, q):
	dist_x = p[0] - q[0]
	dist_y = p[1] - q[1]
	return [q[0] - dist_x, q[1] - dist_y]


def symmetric_point(p, q):
	distance_to_p_x = p[0] - q[0]
	distance_to_p_y = p[1] - q[1]
	return [q[0] - distance_to_p_x, q[1] - distance_to_p_y]


def symmetric_point(p, q):
	pointslist = []
	difference = q[0] - p[0]
	newpoint = q[0] + difference
	difference2 = q[1] - p[1]
	newpoint2 = q[1] + difference2
	pointslist.append(newpoint)
	pointslist.append(newpoint2)
	return pointslist


def symmetric_point(p, q):
	x = []
	x.append(2 * q[0] - p[0])
	x.append(2 * q[1] - p[1])
	return x


def symmetric_point(p, q):
	difference = []
	zip_object = zip(p, q)
	for (p, q) in zip_object:
		difference.append(2 * q - p)
	return difference


def symmetric_point(p, q):
	x = q[0] - p[0]
	x = q[0] + x
	y = q[1] - p[1]
	y = q[1] + y
	return [x, y]


def symmetric_point(p, q):
	d1 = q[0] - p[0]
	d2 = q[1] - p[1]
	return [q[0] + d1, q[1] + d2]


def symmetric_point(p, q):
	if q[0] > p[0]:
		x = q[0] + abs(q[0] - p[0])
	elif q[0] < p[0]:
		x = q[0] - abs(p[0] - q[0])
	else:
		x = p[0]
	if q[1] > p[1]:
		y = q[1] + abs(q[1] - p[1])
	elif q[1] < p[1]:
		y = q[1] - abs(p[1] - q[1])
	else:
		y = p[1]
	return [x, y]


def symmetric_point(p, q):
	distance = []
	for (a, b) in zip(p, q):
		if a > 0 and b > 0:
			distance.append(abs(a - b))
		elif a < 0 and b < 0:
			distance.append(abs(abs(a) - abs(b)))
		else:
			distance.append(abs(a) + abs(b))
	final_point = []
	for (i, c, d) in zip([0, 1], q, distance):
		if p[i] > 0 and q[i] > 0 or (p[i] < 0 and q[i] < 0):
			if abs(p[i]) < abs(q[i]):
				final_point.append(abs(c) + d)
			else:
				final_point.append(abs(c) - d)
		else:
			final_point.append(abs(c) + abs(d))
	return [x * -1 if q[i] < 0 else x for (i, x) in enumerate(final_point)]


def symmetric_point(p, q):
	return [2 * m - a for (a, m) in zip(p, q)]


def symmetric_point(p, q):
	a = q[0] - abs(p[0] - q[0]) if p[0] > q[0] else q[0] + (q[0] - p[0])
	b = q[1] - abs(p[1] - q[1]) if p[1] > q[1] else q[1] + (q[1] - p[1])
	return [a, b]


def symmetric_point(p, q):
	return [abs(p[i] - q[i]) + q[i] if p[i] < q[i] else q[i] - abs(p[i] - q[i]) for i in [0, 1]]


def symmetric_point(p, q):
	[a, b] = p
	[c, d] = q
	p = c - a
	q = d - b
	return [c + p, d + q]


def symmetric_point(p, q):
	deltax = q[0] - p[0]
	deltay = q[1] - p[1]
	p1 = []
	p1.append(q[0] + deltax)
	p1.append(q[1] + deltay)
	return p1


def symmetric_point(p, q):
	return [2 * q[x] - p[x] for x in range(len(q))]


def symmetric_point(p, q):
	xnew = q[0] + (q[0] - p[0])
	ynew = q[1] + (q[1] - p[1])
	return [xnew, ynew]


import numpy as np

def symmetric_point(p, q):
	npp = np.array(p)
	npq = np.array(q)
	return (npq - npp + npq).tolist()


def symmetric_point(p, q):
	(xp, yp, xq, yq) = p + q
	(xd, yd) = (abs(xp - xq), abs(yp - yq))
	return [xq + (xd if xp < xq else -xd), yq + (yd if yp < yq else -yd)]


def symmetric_point(p, q):
	vertical_d = q[1] - p[1]
	horiz_d = q[0] - p[0]
	vertical_d = vertical_d * -1
	horiz_d = horiz_d * -1
	x = q[0] - horiz_d
	y = q[1] - vertical_d
	return [x, y]


def symmetric_point(p, q):
	(px, py) = p
	(qx, qy) = q
	xdist = px - qx
	ydist = py - qy
	return [qx - xdist, qy - ydist]


def symmetric_point(p, q):
	(x1, y1) = p
	(p1, p2) = q
	x2 = p1 * 2 - x1
	y2 = p2 * 2 - y1
	return [x2, y2]


def symmetric_point(p, q):
	(x1, y1) = p
	(x2, y2) = q
	return [x2 + x2 - x1, y2 + y2 - y1]


def symmetric_point(p, q):
	dx = q[0] - p[0]
	dy = q[1] - p[1]
	nx = dx + q[0]
	ny = dy + q[1]
	return [nx, ny]


def symmetric_point(p, q):
	xpos = p[0] < q[0]
	ypos = p[1] < q[1]
	xdiff = max(p[0], q[0]) - min(p[0], q[0])
	ydiff = max(p[1], q[1]) - min(p[1], q[1])
	if xpos:
		x = q[0] + xdiff
	if not xpos:
		x = q[0] - xdiff
	if ypos:
		y = q[1] + ydiff
	if not ypos:
		y = q[1] - ydiff
	return [x, y]


def symmetric_point(p, q):
	arr = []
	for i in zip(p, q):
		x = i[1] - i[0]
		arr.append(i[1] + x)
	return arr


def symmetric_point(p, q):
	c = int(q[0] + (q[0] - p[0]))
	d = int(q[1] + (q[1] - p[1]))
	return [c, d]


def symmetric_point(p, q):
	r1 = -(p[0] - q[0] - q[0])
	r2 = -(p[1] - q[1] - q[1])
	return [r1, r2]


def symmetric_point(p, q):
	return [2 * x[1] - x[0] for x in zip(p, q)]


def symmetric_point(p, q):
	dist_x = q[0] - p[0]
	dist_y = q[1] - p[1]
	p1_x = q[0] + dist_x
	p2_x = q[1] + dist_y
	return [p1_x, p2_x]


def symmetric_point(p, q):
	r = []
	r.append(q[0] - p[0] + q[0])
	r.append(q[1] - p[1] + q[1])
	return r


def symmetric_point(p, q):
	if p[0] > q[0]:
		x0 = q[0] - (p[0] - q[0])
		if p[1] > q[1]:
			y0 = q[1] - (p[1] - q[1])
			return [x0, y0]
		else:
			y0 = q[1] - (p[1] - q[1])
			return [x0, y0]
	else:
		x0 = q[0] - (p[0] - q[0])
		if p[1] > q[1]:
			y0 = q[1] - (p[1] - q[1])
			return [x0, y0]
		else:
			y0 = q[1] - (p[1] - q[1])
			return [x0, y0]


def symmetric_point(a, b):
	return [2 * b[0] - a[0], 2 * b[1] - a[1]]


def symmetric_point(p, q):
	reflected_x = q[0] + (q[0] - p[0])
	try:
		slope = (q[1] - p[1]) / (q[0] - p[0])
		b = p[1] - slope * p[0]
		reflected_y = slope * reflected_x + b
	except ZeroDivisionError:
		reflected_y = p[1]
	return [round(reflected_x), round(reflected_y)]


def symmetric_point(p, q):
	p2_x = p[0] + 2 * (q[0] - p[0])
	p2_y = p[1] + 2 * (q[1] - p[1])
	return [p2_x, p2_y]


def symmetric_point(p, q):
	a = q[0] - p[0]
	b = q[1] - p[1]
	c = a + q[0]
	d = b + q[1]
	return [c, d]


def symmetric_point(p, q):
	return [2 * q[i] - p[i] for i in (0, 1)]


import operator

def symmetric_point(p, q):
	return [i * -1 + j * 2 for (i, j) in zip(p, q)]


def symmetric_point(p, q):
	x1 = int(str(p).split(',')[0].split('[')[1])
	y1 = int(str(p).split(',')[1].split(']')[0])
	x2 = int(str(q).split(',')[0].split('[')[1])
	y2 = int(str(q).split(',')[1].split(']')[0])
	return [x2 + (x2 - x1), y2 + (y2 - y1)]


def symmetric_point(p, q):
	(delta_x, delta_y) = (abs(q[0] - p[0]), abs(q[1] - p[1]))
	return [q[0] + delta_x if p[0] < q[0] else q[0] - delta_x, q[1] + delta_y if p[1] < q[1] else q[1] - delta_y]


def symmetric_point(p, q):
	p_simx = q[0] - p[0]
	p_simy = q[1] - p[1]
	return [q[0] - -p_simx, q[1] - -p_simy]


def symmetric_point(p, q):
	return [y + (y - x) for (x, y) in zip(p, q)]