How do I create this script?


I need to create a program that will
give you the distance between any two points given their ordered pairs.

Would this work?

oInput = ["9.5 7.5", "10.2 19.1", "9.7 10.2"]

inp = [(float(j[0]), float(j[1])) for j in [i.split() for i in oInput]]

min_distance = float('infinity')
min_pair = None

length = len(inp)
for i in xrange(length):
    for j in xrange(i+1, length):
        point1 = inp[i]
        point2 = inp[j]

        if math.hypot(point1[0] - point2[0], point1[1] - point2[0]) < min_distance:
            min_pair = [point1, point2]


Bumping this topic because I still need an answer



Why don't you try it and find out...