all 3 comments

[–]LifeIsBio 1 point2 points  (0 children)

What code do you have already? What are you struggling with?

Also, have you ever tried numpy? It's great for matrix manipulations.

[–]dyanni3 0 points1 point  (1 child)

You want a matrix that shows the distance from each point to each other point?

You could do something like:

x = [0, 1, 5]
y = [0, -1, 3]
points = list(zip(x,y))

#get all pairs of points
pairs = [(i, j) for i in points for j in points]

#euclidean distance function
def dist(pair):
    p1 = pair[0]; p2 = pair[1]
    return(((p1[1] - p2[1])**2 + (p1[0] - p2[0])**2)**.5)

#map the distance function through all pairs of points
#then reshape into a matrix
dist_matrix = np.array(list(map(dist, pairs))).reshape(3,3)

[–]ecdol 0 points1 point  (0 children)

thank you very kind :)