Skip to content

Instantly share code, notes, and snippets.

@talhaahussain
Created June 13, 2024 02:28
Show Gist options
  • Save talhaahussain/60eabb312a103578f181d826c4325252 to your computer and use it in GitHub Desktop.
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.
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