Untitled
unknown
plain_text
8 months ago
754 B
6
Indexable
def canMeet(locations): n = len(locations) # Special case for two points: they will always meet at their midpoint if n == 2: return True # Calculate centroid centroid_x = sum(point[0] for point in locations) / n centroid_y = sum(point[1] for point in locations) / n # Check if all points are symmetric around the centroid for i in range(n): x, y = locations[i] opposite_x, opposite_y = locations[(i + n//2) % n] # Check if each point has a symmetric counterpart if not (2 * centroid_x == x + opposite_x and 2 * centroid_y == y + opposite_y): return False # If they pass the symmetry check, they will meet at the centroid return True
Editor is loading...
Leave a Comment