def pdist(x, y, p=2):
    """Calculates the p-distance between x and y.

    The p-distance between two points is the p-th root of the sum over all
    (x_i - y_i) ^ p.

    By default, the p=2 distance is returned, which is also known as the
    euclidean distance.

    Args:
        x: One point.
        y: Another point.

    Returns:
        The p-distance between x and y.
    """
    result = 0
    for i, x_i in enumerate(x):
        result = result + (x_i - y[i]) ** p
    return result ** (1 / p)