As part of the C++ Nanodegree, one of the projects is to build a route planner using OpenStreetMap. To get to the point of being able to build it, the class covers several different topics. Right now, I am learning about A* search. One of the functions I had to write was a Heuristic function that takes a pair of 2D coordinates on a grid and returns the Manhattan Distance. When I looked at the equation, it jogged my memory — and I remembered back to school when we were learning the Euclidean Distance, and used it to calculate how similar movies were in a Netflix style recommendation system for movies.

This is the way … that one ends up going down a rabbit hole. It was the Manhattan Distance equation that struck me:

∣*x*2−*x*1∣+∣*y*2−*y*1∣

It looked so familiar because the Euclidean Distance equation is similar:

Then, of course I needed to know the difference. Google as usual was both my friend and my foe in this situation. Although the resource I found most helpful was this IEEE student presentation from Morocco, titled “DISTANCES IN CLASSIFICATION” from July of 2016. Ironically, this date is around the time I was doing a deep dive into the Euclidean Distance. The presentation not only describes the Euclidean Distance and Manhattan Distance, but several others, which could have led me further down the rabbit hole – but it did not. I was excited to code the function and move on!