import numpy as np
import math


def euclidean_distance(a, b):
    if isinstance(a, list) and isinstance(b, list):
        a = np.array(a)
        b = np.array(b)

    return math.sqrt(sum((a - b) ** 2))


def l2_distance(X):
    '''
    [<------x0----->]
    [<------x1----->]
    [<------x2----->]
    .
    .
    .
    '''
    sum_X = np.sum(X * X, axis=1)
    return (-2 * np.dot(X, X.T) + sum_X).T + sum_X
