Skip to content
Map Cordinates Python
Profile icon

A road map defines locations as map references like B3, where B is the x-coordinate value and 3 is the y-coordinate.


The grid lines are 0.5 km apart.

I'm writing a program that allows the user to enter a trip as a sequence of any number of map references on one line, and reports the total length of the trip, assuming they can travel in straight lines.
Like in the below picture:


Can please somebody instruct me how to do this?

You are viewing a single comment. View All
Answered by SixBeeps [earned 5 cycles]
View Answer
Profile icon

For the distance formula, you should only need your language's sqrt function, then just do simple mathematical functions from there.

For the letter conversion, I'd do something like

arrayOfLetters = ['A', 'B', 'C', ... , 'Y', 'Z'] indexOfT = arrayOfLetters.index('T')