diff --git a/constellation.py b/constellation.py new file mode 100644 index 0000000..1519451 --- /dev/null +++ b/constellation.py @@ -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)):