from math import dist
from math import turtle
f = open('file.txt')
a = [list(map(float, i.replace(',', '.').split())) for i in f]
def dbscan(points, r):
clusters = []
while points:
clusters.append([points.pop(0)])
for point in clusters[-1]:
for neighbor in points[:]:
if dist(point, neighbor) < r:
clusters[-1].append(neighbor)
points.remove(neighbor)
return clusters
clusters = dbscan(a, 0.3)
centers = []
for cluster in clusters:
mn = 10**20
centroid = []
for center in cluster:
s = 0
for star in cluster:
s += dist(center, star)
if s < mn:
mn = s
centroid = center
px += centroid[0]
py += centroid[1]
centers.append(centroid)
print(int(abs(px/len(clusters)) * 10000), int(abs(py/len(clusters)) * 10000))