Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Add the calculation of Manhattan Distance #7776

Closed
@carlos3dx

Description

@carlos3dx

Feature description

The Manhattan distance (also known as taxicab distance) measures the distance between two points in a n-dimensional grid only taking into account the diference between each coordinate point instead of using the Euclidean distance.

For example, you want to go by taxi from point a to b in a city with a grid layout like Manhattan, the shortest path should be a straight line but it would require the cab going through buildings, the real distance requires going along the streets and making turns utntil you reach the destination.

The function must receive two points in the same n-dimensional space and each component is a real number, but the output shall be the calculated with the Manhattan distance instead of the Euclidean one.

Example

manhattan_distance([1,1], [2,2]) -> 2
manhattan_distance([1.5,1.5], [2,2]) -> 1
manhattan_distance([1.5,1.5], [2.5,2]) -> 1.5

Would you like to work on this feature?

  • Yes, I want to work on this feature!

Metadata

Metadata

Assignees

Labels

enhancementThis PR modified some existing files

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions