I've been trying to craft a Manhattan distance function in Python.
However, it seems quite straight forward but I am having trouble.
Can anyone help me out with Manhattan distance metric written in Python?
Thanks in advance,
Smitty
Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!
#This operation returns the Manhattan distance. # def getManhattan(xList,yList): return float(xList[0]-xList[1]) + abs(yList[0]-yList[1])As a note here, you may need to swap the 1 and 0 around, depending on how you are storing points. I would expect xList[1]-xList[0] + yList[1]-yList[0] to be closer to what you need, but I'm not sure how exactly you are storing points, so I can't be 100% certain.
0 members, 0 guests, 0 anonymous users
Community Forum Software by IP.Board
Licensed to: Geeks to Go, Inc.