Created
June 13, 2024 02:28
-
-
Save talhaahussain/60eabb312a103578f181d826c4325252 to your computer and use it in GitHub Desktop.
manhattan_distance.py -- A Python program for computing the distance between two n-dimensional points in Manhattan geometry, using Cartesian coordinates, where each point is represented as a list of n length.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def distance(a: list[int], b: list[int]) -> list[int]: | |
assert len(a) == len(b), "Coordinates must be in same dimension." | |
return [abs((a[i] - b[i])) for i in range(len(a))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment