The medians of a triangle are the segments that unit the vertices with the midpoint of their opposite sides.
The three medians of a triangle intersect at the same point, called the barycenter or the centroid.
Given a triangle, defined by the cartesian coordinates of its vertices we need to localize its barycenter or centroid.

The function ```bar_triang() or barTriang or bar-triang```, receives the coordinates of the three vertices ```A, B and C ``` as three different arguments and outputs the coordinates of the barycenter ```O``` in an array ```[xO, yO]```

This is how our asked function should work:
the result of the coordinates should be expressed up to four decimals, (rounded result).

You know that the coordinates of the barycenter are given by the following formulas.



For additional information about this important point of a triangle see at: (https://en.wikipedia.org/wiki/Centroid)

Let's see some cases:
```python
bar_triang([4, 6], [12, 4], [10, 10]) ------> [8.6667, 6.6667]

bar_triang([4, 2], [12, 2], [6, 10] ------> [7.3333, 4.6667]
```
The given points form a real or a degenerate triangle but in each case the above formulas can be used.

Enjoy it and happy coding!!

Source: codewars | Difficulty: EASY
Tags: Geometry

Fundamentals

Mathematics

Starter code: def bar_triang(pointA, pointB, pointC):
	

Solutions:
def bar_triang(a, b, c):
	return [round(sum(x) / 3.0, 4) for x in zip(a, b, c)]


def bar_triang(pointA, pointB, pointC):
	a = (pointA[0] + pointB[0] + pointC[0]) / 3.0
	b = (pointA[1] + pointB[1] + pointC[1]) / 3.0
	return [round(a, 4), round(b, 4)]


def bar_triang(pointA, pointB, pointC):
	return [round((pointA[0] + pointB[0] + pointC[0]) / 3.0, 4), round((pointA[1] + pointB[1] + pointC[1]) / 3.0, 4)]


def bar_triang(*args):
	return [round(sum(a) / 3.0, 4) for a in zip(*args)]


bar_triang = lambda *points: [round(sum(point) / 3.0, 4) for point in zip(*points)]


from numpy import mean

def bar_triang(*points):
	return [round(mean(dim), 4) for dim in zip(*points)]


def bar_triang(x, y, z):
	return [round(float(x[0] + y[0] + z[0]) / 3, 4), round(float(x[1] + y[1] + z[1]) / 3, 4)]


def bar_triang(A, B, C):
	return [round(sum(axis) / 3.0, 4) for axis in zip(A, B, C)]


def bar_triang(*points):
	return [round(sum(x) / 3.0, 4) for x in zip(*points)]


bar_triang = lambda *p: [round(sum(z) / 3.0, 4) for z in zip(*p)]


def bar_triang(*pts):
	return [round(1.0 * sum(ps) / len(pts), 4) for ps in zip(*pts)]


def bar_triang(*coords):
	return [round(1.0 * sum(c) / len(coords), 4) for c in zip(*coords)]


import numpy as np

def bar_triang(*points):
	return np.mean(points, axis=0).round(4).tolist()


def bar_triang(p1, p2, p3):
	return [float('%2.4f' % ((p1[0] + p2[0] + p3[0]) / 3.0)), float('%2.4f' % ((p1[1] + p2[1] + p3[1]) / 3.0))]


bar_triang = lambda *args: [round(sum((a[0] for a in args)) / 3.0, 4), round(sum((a[1] for a in args)) / 3.0, 4)]


def bar_triang(pointA, pointB, pointC):
	xO = '{:.4f}'.format(float(pointA[0] + pointB[0] + pointC[0]) / 3)
	yO = '{:.4f}'.format(float(pointA[1] + pointB[1] + pointC[1]) / 3)
	return [float(xO), float(yO)]


def bar_triang(pa, pb, pc, n=3.0, r=round):
	return [r((pa[0] + pb[0] + pc[0]) / n, 4), r((pa[1] + pb[1] + pc[1]) / n, 4)]


def bar_triang(a, b, c):
	x0 = (a[0] + b[0] + c[0]) / 3
	y0 = (a[1] + b[1] + c[1]) / 3
	return [round(x0, 4), round(y0, 4)]


def bar_triang(a, b, c):
	xO = round((a[0] + b[0] + c[0]) / 3, 4)
	yO = round((a[1] + b[1] + c[1]) / 3, 4)
	return [xO, yO]


def bar_triang(pointA, pointB, pointC):
	x = sum([pointA[0], pointB[0], pointC[0]]) / 3.0
	y = sum([pointA[1], pointB[1], pointC[1]]) / 3.0
	return [round(x, 4), round(y, 4)]


def bar_triang(pointA, pointB, pointC):
	(x1, y1) = pointA
	(x2, y2) = pointB
	(x3, y3) = pointC
	x0 = (x1 + x2 + x3) / 3
	y0 = (y1 + y2 + y3) / 3
	return [round(x0, 4), round(y0, 4)]


def bar_triang(pointA, pointB, pointC):
	return [round(sum(i) / 3, 4) for i in zip(pointA, pointB, pointC)]


def bar_triang(A, B, C):
	xO = round(sum((x[0] for x in (A, B, C))) / 3, 4)
	yO = round(sum((x[1] for x in (A, B, C))) / 3, 4)
	return [xO, yO]


def bar_triang(pointA, pointB, pointC):
	x_0 = round((pointA[0] + pointB[0] + pointC[0]) / 3, 4)
	y_0 = round((pointA[1] + pointB[1] + pointC[1]) / 3, 4)
	return [x_0, y_0]


def bar_triang(pointA, pointB, pointC):
	return list(map(lambda x: round(sum(x) / 3, 4), zip(pointA, pointB, pointC)))


def bar_triang(a, b, c):
	return list(map(lambda p: round(sum(p) / 3, 4), zip(*(a, b, c))))


def bar_triang(pointA, pointB, pointC):
	return [round((pointA[i] + pointB[i] + pointC[i]) / 3, 4) for i in range(2)]


def bar_triang(pointA, pointB, pointC):
	x0 = (pointA[0] + pointB[0] + pointC[0]) / 3
	y0 = (pointA[1] + pointB[1] + pointC[1]) / 3
	return [round(x0, 4), round(y0, 4)]


def bar_triang(pa, pb, pc):
	(xa, ya) = pa
	(xb, yb) = pb
	(xc, yc) = pc
	xO = round((xa + xb + xc) / 3, 4)
	yO = round((ya + yb + yc) / 3, 4)
	return [xO, yO]


def bar_triang(pointA, pointB, pointC):
	xO = round(sum((x[0] for x in [pointA, pointB, pointC])) / 3, 4)
	yO = round(sum((y[1] for y in [pointA, pointB, pointC])) / 3, 4)
	return [xO, yO]


def bar_triang(pointA, pointB, pointC):
	mod = lambda indx: round(sum(list([_[indx] for _ in [pointA, pointB, pointC]])) / 3, 4)
	return [mod(0), mod(1)]


import math

def bar_triang(a, b, c):
	x = round((a[0] + b[0] + c[0]) / 3, 4)
	y = round((a[1] + b[1] + c[1]) / 3, 4)
	return [x, y]


def bar_triang(a, b, c):
	return [round((a[i] + b[i] + c[i]) / 3, 4) for i in range(len(a))]


def bar_triang(pointA, pointB, pointC):
	x_bary = round((pointA[0] + pointB[0] + pointC[0]) / 3, 4)
	y_bary = round((pointA[1] + pointB[1] + pointC[1]) / 3, 4)
	return [x_bary, y_bary]


def bar_triang(A, B, C):
	return [round((A[0] + B[0] + C[0]) / 3, 4), round((A[-1] + B[-1] + C[-1]) / 3, 4)]


def bar_triang(p1, p2, p3):
	return [round((p1[0] + p2[0] + p3[0]) / 3, 4), round((p1[1] + p2[1] + p3[1]) / 3, 4)]


def bar_triang(pointA, pointB, pointC):
	x = (pointA[0] + pointB[0] + pointC[0]) / 3
	y = (pointA[1] + pointB[1] + pointC[1]) / 3
	return [round(x * 10000) / 10000, round(y * 10000) / 10000]


def bar_triang(*dots):
	x_sum = y_sum = 0
	for d in dots:
		x_sum += d[0]
		y_sum += d[1]
	xO = f'{x_sum / 3:.4f}'
	yO = f'{y_sum / 3:.4f}'
	return [float(xO), float(yO)]


def bar_triang(a, b, c):
	return [round((a[i] + b[i] + c[i]) / 3, 4) for i in (0, 1)]


def bar_triang(pointA, pointB, pointC):
	xO = (pointA[0] + pointB[0] + pointC[0]) / 3
	yO = (pointA[1] + pointB[1] + pointC[1]) / 3
	xO = round(xO, 4)
	yO = round(yO, 4)
	return [xO, yO]


def bar_triang(pA, pB, pC):
	return [round((pA[0] + pB[0] + pC[0]) / 3, 4), round((pA[1] + pB[1] + pC[1]) / 3, 4)]


def bar_triang(pointA, pointB, pointC):
	return [round(sum((x / 3 for (x, _) in [pointA, pointB, pointC])), 4), round(sum((y / 3 for (_, y) in [pointA, pointB, pointC])), 4)]


def bar_triang(pA, pB, pC):
	xO = round((pA[0] + pB[0] + pC[0]) / 3, 4)
	yO = round((pA[1] + pB[1] + pC[1]) / 3, 4)
	return [xO, yO]


def bar_triang(pointsA, pointsB, pointsC):
	return [round((pointsA[0] + pointsB[0] + pointsC[0]) / 3, 4), round((pointsA[1] + pointsB[1] + pointsC[1]) / 3, 4)]


def bar_triang(A, B, C):
	x = round((A[0] + B[0] + C[0]) / 3, 4)
	y = round((A[1] + B[1] + C[1]) / 3, 4)
	return [x, y]


def bar_triang(*p):
	return list([round(sum(x) / 3, 4) for x in zip(*p)])


def bar_triang(A, B, C):
	x0 = (A[0] + B[0] + C[0]) / 3
	y0 = (A[1] + B[1] + C[1]) / 3
	return [round(x0, 4), round(y0, 4)]


def bar_triang(pointA, pointB, pointC):
	x0 = float(f'{(pointA[0] + pointB[0] + pointC[0]) / 3: .4f}')
	y0 = float(f'{(pointA[1] + pointB[1] + pointC[1]) / 3: .4f}')
	return [x0, y0]


def bar_triang(pointA, pointB, pointC):
	(x, y, lst) = (0, 0, [pointA, pointB, pointC])
	for i in range(3):
		x += lst[i][0]
		y += lst[i][1]
	return [round(x / 3, 4), round(y / 3, 4)]


from statistics import mean

def bar_triang(pointA, pointB, pointC):
	return [round(mean(row), 4) for row in zip(pointA, pointB, pointC)]


def bar_triang(A, B, C):
	xO = (A[0] + B[0] + C[0]) / 3
	yO = (A[1] + B[1] + C[1]) / 3
	return [round(xO, 4), round(yO, 4)]


bar_triang = lambda a, b, c: [round((abs(a[0] + b[0]) + abs(a[0] + c[0]) + abs(b[0] + c[0])) / 6, 4), round((abs(a[1] + b[1]) + abs(a[1] + c[1]) + abs(b[1] + c[1])) / 6, 4)]


import numpy as np

def bar_triang(pointA, pointB, pointC):
	x0 = np.around((pointA[0] + pointB[0] + pointC[0]) / 3, decimals=4)
	y0 = np.around((pointA[1] + pointB[1] + pointC[1]) / 3, decimals=4)
	return [x0, y0]


def bar_triang(pointA, pointB, pointC):
	(xa, xb, xc) = (pointA[0], pointB[0], pointC[0])
	(ya, yb, yc) = (pointA[1], pointB[1], pointC[1])
	x = round((xa + xb + xc) / 3, 4)
	y = round((ya + yb + yc) / 3, 4)
	return [x, y]


bar_triang = lambda A, B, C: [round(sum(i) / 3, 4) for i in zip(A, B, C)]


def bar_triang(pointA, pointB, pointC):
	(x1, x2, x3) = (pointA[0], pointB[0], pointC[0])
	(y1, y2, y3) = (pointA[1], pointB[1], pointC[1])
	return [round((x1 + x2 + x3) / 3, 4), round((y1 + y2 + y3) / 3, 4)]


def bar_triang(pointA, pointB, pointC):
	xo = round((pointA[0] + pointB[0] + pointC[0]) / 3, 4)
	yo = round((pointA[1] + pointB[1] + pointC[1]) / 3, 4)
	return [xo, yo]


def bar_triang(pointA, pointB, pointC):
	(xa, ya) = pointA
	(xb, yb) = pointB
	(xc, yc) = pointC
	xO = round((xa + xb + xc) / 3, 4)
	yO = round((ya + yb + yc) / 3, 4)
	return [xO, yO]


from typing import List

def bar_triang(a: List[int], b: List[int], c: List[int]) -> List[float]:
	return [round((a[0] + b[0] + c[0]) / 3, 4), round((a[1] + b[1] + c[1]) / 3, 4)]


def bar_triang(pointA, pointB, pointC):
	return [round(i, 4) for i in list(map(lambda x, y, z: (x + y + z) / 3, pointA, pointB, pointC))]


bar_triang = lambda a, b, c: [round((a[0] + b[0] + c[0]) / 3, 4), round((a[1] + b[1] + c[1]) / 3, 4)]


def bar_triang(pointA, pointB, pointC):
	(xA, yA) = pointA
	(xB, yB) = pointB
	(xC, yC) = pointC
	x0 = (xA + xB + xC) / 3
	y0 = (yA + yB + yC) / 3
	return [round(x0, 4), round(y0, 4)]


def bar_triang(a, b, c):
	return [round((a[0] + b[0] + c[0]) / 3, 4), round((a[1] + b[1] + c[1]) / 3, 4)]


import numpy as np

def bar_triang(pointA, pointB, pointC):
	return [np.round((pointA[0] + pointB[0] + pointC[0]) / 3, 4), np.round((pointA[1] + pointB[1] + pointC[1]) / 3, 4)]


def bar_triang(pointA, pointB, pointC):
	return [round((a + b + c) / 3, 4) for (a, b, c) in zip(pointA, pointB, pointC)]


def bar_triang(*points):
	center_x = sum((point[0] for point in points)) / len(points)
	center_y = sum((point[1] for point in points)) / len(points)
	return [round(center_x, 4), round(center_y, 4)]


def bar_triang(pA, pB, pC):
	x = round((pA[0] + pB[0] + pC[0]) / 3, 4)
	y = round((pA[1] + pB[1] + pC[1]) / 3, 4)
	return [x, y]


def bar_triang(pointA, pointB, pointC):
	(ax, ay) = pointA
	(bx, by) = pointB
	(cx, cy) = pointC
	x0 = round((ax + bx + cx) / 3, 4)
	y0 = round((ay + by + cy) / 3, 4)
	return [x0, y0]