I need a function that finds the biggest value and prints its coordinates. In case of more than one maximum element, that all of them should be printed.
Example of distance matrix:
[[0. 0.4 0.66666667 0.85714286]
[0.4 0. 0.4 0.85714286]
[0.66666667 0.4 0. 1. ]
[0.85714286 0.85714286 1. 0. ]]
My function, which gives only the last largest distance:
def maxelement(arr):
cords = []
no_of_rows = len(arr)
no_of_column = len(arr[0])
for i in range(no_of_rows):
max1 = 0
for j in range(no_of_column):
if arr[i][j] > max1 :
max1 = arr[i][j]
o = i
a = j
cords.append(a+1)
cords.append(o+1)
print("The biggest distance is:", max1,", for sets:", cords)