def _build_lcs_matrix(seq1, seq2):
    """
    Given two sequences seq1 and seq2:
    Build a matrix of zero's len(seq1) + 1 x len(seq2) + 1 in size which
    provides a numerical map which can be 'backtracked' to  find the largest
    common sub-sequences.

    Matrix build procedure:
        - Leave the first row and collumn as zeros
        - Step through seq1 and seq2:
            -if you find a match:
                Grab the value diagonally backwards from where you are in
                the matrix (left, up) and add 1 to it. (you essentially
                create a representation of the increasing sizes of
                subsequences).
            -else:
                Inspect the values above and to the left of you and pick the
                larger of the two; if they're equal it's an arbitrary
                choice. The subsequence hasn't increased here because there
                is no match, but you want to maintain the size of it so far.

    see https://en.wikipedia.org/wiki/Longest_common_subsequence_problem
    for further details and diagramatic explanations.
    """
    matrix = [[(0) for i in range(len(seq1) + 1)] for i in range(len(seq2) + 1)
        ]
    for i, i_val in enumerate(seq1):
        for j, j_val in enumerate(seq2):
            m_i = i + 1
            m_j = j + 1
            if i_val == j_val:
                diagonally_back = matrix[m_j - 1][m_i - 1]
                val = diagonally_back + 1
            else:
                up = matrix[m_j - 1][m_i]
                left = matrix[m_j][m_i - 1]
                val = max(up, left)
            matrix[m_j][m_i] = val
    return matrix
