started constellation problem

This commit is contained in:
Tommaso Rodolfo Masera 2019-05-02 17:01:00 +02:00
parent 374b8f3cf5
commit 6f352fd6cc

21
constellation.py Normal file
View file

@ -0,0 +1,21 @@
class Star:
def __init__(self, x, y):
self.x = x
self.y = y
def distance_sqr(self, other):
return ((self.x - other.x) ** 2) + ((self.y - other.y) ** 2))
def return_key(A):
return A[2] << 32
def find_constellation(S):
T = []
for i in range(len(S)):
for j in range(i + 1, len(S)):
T.append( (S[i], S[j], S[i].distance_sqr(S[j])) )
T.sort(key=return_key)
cnt = 0
for i in range(len(T)):