Find a point such that sum of the Manhattan distances is minimized | Function to print the required points which minimizes the sum of Manhattan distances ; Sorting points in all dimension ; Output the required k points ; Driver code ; function call to print required points
def minDistance ( n , k , point ) : NEW_LINE INDENT for i in range ( k ) : NEW_LINE INDENT point [ i ] . sort ( ) NEW_LINE DEDENT for i in range ( k ) : NEW_LINE INDENT print ( point [ i ] [ ( ( n + 1 ) // 2 ) - 1 ] , end = " ▁ " ) NEW_LINE DEDENT DEDENT n = 4 NEW_LINE k = 4 NEW_LINE point = [ [ 1 , 5 , 2 , 4 ] , [ 6 , 2 , 0 , 6 ] , [ 9 , 5 , 1 , 3 ] , [ 6 , 7 , 5 , 9 ] ] NEW_LINE minDistance ( n , k , point ) NEW_LINE