guess-the-triangle

You are given 3 points - middles of the sides of some triangle. Find coordinates of the triangle vertices.

Input
Input  has 3 lines with 2 space-separated reals each - coordinates of the middles of the sides.

Output
Output 3 lines with 2 space-separated reals - coordinates of the triangle vertices. Each number should have exactly 4 digits after dot.  Vertices should be sorted in first coordinate ascending order. If two points have the same first coordinate than they should have second coordinate ascending order.

Constraints
0 ≤ xi, yi ≤ 1000

SAMPLE INPUT
5.00 3.00
4.0 4.0
5.0 5.000

SAMPLE OUTPUT
4.0000 2.0000
4.0000 6.0000
6.0000 4.0000

Source: hackerearth | Difficulty: EASY
Tags: Geometry


Solutions:
l = input()
x1 = float(l.split()[0])
y1 = float(l.split()[1])

l = input()
x2 = float(l.split()[0])
y2 = float(l.split()[1])

l = input()
x3 = float(l.split()[0])
y3 = float(l.split()[1])

a1 = x1 - x2 + x3
a2 = 2*x1 - a1
a3 = 2*x2 - a2

b1 = y1 - y2 + y3
b2 = 2*y1 - b1
b3 = 2*y2 - b2

l = [[a1,b1],[a2,b2],[a3,b3]]
l.sort()

for e in l:
	print("%.4f %.4f"% (e[0],e[1]))



def solve(cord):
	res = []
	x = cord[0][0] + cord[1][0] + cord[2][0]
	y = cord[0][1] + cord[1][1] + cord[2][1]
	res.append((x-2*cord[2][0], y-2*cord[2][1]))
	res.append((x-2*cord[1][0], y-2*cord[1][1]))
	res.append((x-2*cord[0][0], y-2*cord[0][1]))
	res.sort(key= lambda x : (x[0], x[1]))
	for x in res:
		print('%1.4f %1.4f'%(x[0], x[1]))
		
if __name__ == '__main__':
	cords = []
	for i in range(3):
		cords.append(list(map(float, input().split(' '))))
	solve(cords)



x=[]
y=[]
xs=0
ys=0
for i in range(0,3):
	s=input()
	s=s.split()
	xs=xs+float(s[0])
	x.append(2*float(s[0]))
	ys=ys+float(s[1])
	y.append(2*float(s[1]))
xc=[]
yc=[]
for i in range(0,3):
	xc.append(xs-x[i])
	yc.append(ys-y[i])
for i in range(0,3):
	for j in range(0,3-i-1):
		if xc[j]>xc[j+1]:
			xc[j],xc[j+1]=xc[j+1],xc[j]
			yc[j],yc[j+1]=yc[j+1],yc[j]
		if(xc[j]==xc[j+1]):
			if yc[j]>yc[j+1]:
				xc[j],xc[j+1]=xc[j+1],xc[j]
				yc[j],yc[j+1]=yc[j+1],yc[j]
for i in range(0,3):
	print(("%.4f" % xc[i]), end=' ')
	print(("%.4f" % yc[i]))


#!/usr/bin/py

x=[]
y=[]
for i in range(0,3):
	a=input()
	x.append(float(a.split()[0]))
	y.append(float(a.split()[1]))
sumx = x[0] + x[1] + x[2]
sumy = y[0] + y[1] + y[2]
a=[]
for i in range(0,3):
	a.append((sumx - 2*x[i], sumy-2*y[i]))
a.sort()
for i in a:
	print("%.4f %.4f"%(i[0], i[1]) )
# print '%.4f' % a[0][0]


midpts = []

for index in range(3):
	x1,y1 = list(map(float,input().split()))
	midpts.append([x1,y1])
	
#print midpts

sumx = midpts[0][0] + midpts[1][0] + midpts[2][0]
sumy = midpts[0][1] + midpts[1][1] + midpts[2][1]

pts = []
pts.append([sumx-2*midpts[0][0],sumy-2*midpts[0][1]])
pts.append([sumx-2*midpts[1][0],sumy-2*midpts[1][1]])
pts.append([sumx-2*midpts[2][0],sumy-2*midpts[2][1]])

#print pts

pts.sort(key = lambda x: [x[0],x[1]])

for pt in pts:
	print("%0.4f %0.4f" % (pt[0], pt[1]))


mx1, my1 = list(map(float, input().split()))
mx2, my2 = list(map(float, input().split()))
mx3, my3 = list(map(float, input().split()))
v = [((mx1+mx2 -mx3),(my1+my2-my3)),((mx2+mx3 -mx1),(my2+my3-my1)), ((mx3+mx1 -mx2),(my3+my1-my2))]
v.sort()
for i in v:
	print("%.4f"%i[0],"%.4f"%i[1])
#print "%.4f"%(mx1+mx2 -mx3),"%.4f"%(my1+my2-my3)	
#print "%.4f"%(mx2+mx3 -mx1),"%.4f"%(my2+my3-my1)
#print "%.4f"%(mx3+mx1 -mx2),"%.4f"%(my3+my1-my2)


a=input().split()
Xm1, Ym1 = float(a[0]), float(a[1])

a=input().split()
Xm2, Ym2 = float(a[0]), float(a[1])

a=input().split()
Xm3, Ym3 = float(a[0]), float(a[1])


Xg = Xm1 + Xm2 + Xm3

Yg = Ym1 + Ym2 + Ym3

li = [(Xg - 2*Xm3, Yg - 2*Ym3), (Xg - 2*Xm2, Yg - 2*Ym2), (Xg - 2*Xm1, Yg - 2*Ym1)]

li.sort()

for i in li:
	print('%.4f %.4f' % i)


a,b=list(map(float,input().split()))
c,d=list(map(float,input().split()))
e,f=list(map(float,input().split()))

a,b,c,d,e,f=2*a,2*b,2*c,2*d,2*e,2*f

#x,y  m,n   r,s

x=(c+e-a)/2
m=(c+a-e)/2
r=(a+e-c)/2

y=(d+f-b)/2
n=(d+b-f)/2
s=(b+f-d)/2


arr=[[x,y],[m,n],[r,s]]
arr=sorted(arr)

for item in arr:
	for it in item:
		print(("{0:.4f}".format(it)), end=' ')
		
	print("")

'''
print x,
print y

print m,
print n

print r,
print s

'''


x1,y1=list(map(float,input().split(" ")))
x2,y2=list(map(float,input().split(" ")))
x3,y3=list(map(float,input().split(" ")))

a1 = x1 - x2 + x3
a2 = 2*x1 - a1
a3 = 2*x2 - a2
 
b1 = y1 - y2 + y3
b2 = 2*y1 - b1
b3 = 2*y2 - b2

sides=[[a1,b1],[a2,b2],[a3,b3]]
for side in sorted(sides):
	print("%.4f %.4f"% (side[0],side[1]))


from operator import itemgetter

a1,a2=list(map(float,input().split()))
b1,b2=list(map(float,input().split()))
c1,c2=list(map(float,input().split()))
 
x1=a1+b1-c1
y1=b1+c1-a1
z1=c1+a1-b1

x2=a2+b2-c2
y2=b2+c2-a2
z2=c2+a2-b2

points=[(x1,x2),(y1,y2),(z1,z2)]
points.sort(key=itemgetter(0,1),reverse=False)

print(("%.4f %.4f" %(points[0][0],points[0][1])))
print(("%.4f %.4f" %(points[1][0],points[1][1])))
print(("%.4f %.4f" %(points[2][0],points[2][1])))




a1,a2 = list(map(float,input().split()))
b1,b2 = list(map(float,input().split()))
c1,c2 = list(map(float,input().split()))

x1 = (c1-b1+a1)
x2 = (c1+b1-a1)
x3 = (b1-c1+a1)

y1 = (c2-b2+a2)
y2 = (c2+b2-a2)
y3 = (b2-c2+a2)

arr = []
arr.append((x1,y1))
arr.append((x2,y2))
arr.append((x3,y3))

arr.sort()

for i in arr:
	x,y = i
	print("%.4f"%x, end=' ')
	print("%.4f"%y)


ary = [list(map(float,input().split())) for i in range(3)]
ans = [(ary[0][0]-ary[1][0]+ary[2][0],ary[0][1]-ary[1][1]+ary[2][1]), (ary[0][0]+ary[1][0]-ary[2][0],ary[0][1]+ary[1][1]-ary[2][1]), (-ary[0][0]+ary[1][0]+ary[2][0],-ary[0][1]+ary[1][1]+ary[2][1])]
ans.sort()
for i in ans:
	print("%.4f %.4f"%(i[0],i[1]))


a,b=list(map(float, input().split()))
c,d=list(map(float, input().split()))
e,f=list(map(float, input().split()))
g=a+c+e
h=b+d+f
a*=2
b*=2
c*=2
d*=2
e*=2
f*=2
x=[]
x.append([g-a,h-b])
x.append([g-c,h-d])
x.append([g-e,h-f])
x.sort()
for i in x:
	print('%.4f %.4f'%(i[0],i[1]))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def QUICKSORT(A,B, p, r):
	if p < r:
	 q = PARTITION(A,B, p, r)
	 QUICKSORT(A,B, p, q-1)
	 QUICKSORT(A,B, q+1, r)
def PARTITION(A,B, p, r):
	x = A[r]
	i =p- 1
	for j in range(p,r):
	 if A[j] < x:
		i =i+1
		A[i],A[j]=A[j],A[i]
		B[i],B[j]=B[j],B[i]
	A[i+1],A[r]=A[r],A[i+1]
	B[i+1],B[r]=B[r],B[i+1]
	return i+1
a1,b1=[float(x) for x in input().split()]
a2,b2=[float(x) for x in input().split()]
a3,b3=[float(x) for x in input().split()]
x1=(2*(a1)-2*(a2)+2*(a3))/2
x3=(2*a1)-x1
x2=(2*a2)-x3
y1=(2*(b1)-2*(b2)+2*(b3))/2
y3=(2*b1)-y1
y2=(2*b2)-y3
x=[x1,x2,x3]
y=[y1,y2,y3]

QUICKSORT(x,y,0,2)
if x[0]==x[1]==x[2]:
	y.sort()
elif x[0]==x[1]:
	if y[0]>y[1]:
		y[0],y[1]=y[1],y[0]
elif x[1]==x[2]:
		 if y[1]>y[2]:
		y[1],y[2]=y[2],y[1]
print("{0:.4f}".format(x[0])+" " +"{0:.4f}".format(y[0]))
print("{0:.4f}".format(x[1])+" " +"{0:.4f}".format(y[1]))
print("{0:.4f}".format(x[2])+" " +"{0:.4f}".format(y[2]))