input list X's shape :【N,2】;
return:max pairwise distance using the bubblesort function

input list X's shape :【N,2】;
return:max pairwise distance using the bubblesort function

关注问题中没有提供冒泡函数,所以得先写一个冒泡排序函数。如果题主有,请自行替换。
>>> def bubblesort(arr):
result = arr[:]
for i in range(len(arr)-1):
for j in range(len(arr)-1-i):
if result[j] > result[j+1]:
result[j], result[j+1] = result[j+1], result[j]
return result
>>> bubblesort([3,8,2,6,7,1,4]) # 测试冒泡排序
[1, 2, 3, 4, 6, 7, 8]
>>> def max_paipwise_distance(x):
dist = list()
for i in range(len(x)-1):
for j in range(i+1, len(x)):
dist.append(pow((pow(x[i][0]-x[j][0], 2) + pow(x[i][1]-x[j][1], 2)), 0.5))
return bubblesort(dist)[-1]
>>> max_paipwise_distance([[3,4], [0,0], [-3,-4]]) # 测试
10.0