Maximum Manhattan distance between a distinct pair from N coordinates | Function to calculate the maximum Manhattan distance ; List to store maximum and minimum of all the four forms ; Sorting both the vectors ; Driver code ; Given Co - ordinates ; Function call
def MaxDist ( A , N ) : NEW_LINE INDENT V = [ 0 for i in range ( N ) ] NEW_LINE V1 = [ 0 for i in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT V [ i ] = A [ i ] [ 0 ] + A [ i ] [ 1 ] NEW_LINE V1 [ i ] = A [ i ] [ 0 ] - A [ i ] [ 1 ] NEW_LINE DEDENT V . sort ( ) NEW_LINE V1 . sort ( ) NEW_LINE maximum = max ( V [ - 1 ] - V [ 0 ] , V1 [ - 1 ] - V1 [ 0 ] ) NEW_LINE print ( maximum ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 3 NEW_LINE A = [ [ 1 , 2 ] , [ 2 , 3 ] , [ 3 , 4 ] ] NEW_LINE MaxDist ( A , N ) NEW_LINE DEDENT