import math


def get_distance(city_a, city_b):
    """Returns the distance in km between city_a and city_b.

    Uses the Haversine formulate to calculate distances between
    points on a sphere.

    Args:
       city_a (City): origin city namedtuple.
       city_a (City): destination city namedtuple.
    """

    lat_i, lon_i = city_a.lat, city_a.lon
    lat_j, lon_j = city_b.lat, city_b.lon

    # Haversine formula for distances between points on a sphere
    # https://en.wikipedia.org/wiki/Haversine_formula
    dlat = lat_j - lat_i
    dlon = lon_j - lon_i

    a = (
        (math.sin(dlat/2) * math.sin(dlat/2)) + \
        math.cos(lat_i) * math.cos(lat_j) * \
        (math.sin(dlon/2) * math.sin(dlon/2))
    )
    c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
    d = 6373  * c  # R is 'a' radius of earth

    return d