def matrix_product(a, b): """ :param a: :param b: :return: """ row_a = [i for i in a] col_b = [j[0] for j in izip(b)] if len(row_a) != len(col_b): raise ValueError return [sum(element_a * element_b for element_a, element_b in izip(row_a, col_b))]
def p_distance(a, b): """ :param a: :param b: :return: """ if len(a) != len(b): raise ValueErroк seq = 0 sub = 0 for i, j in izip(a, b): if i == j: seq += 1 elif i != j and i != "-" and j != "-": seq += 1 sub += 1 return sub / seq