def build_lengths_matrix(str1, str2):
 matrix = [[0 for j in range((len(str2) + 1))] for i in range((len(str1) + 1))]
 for (i, x) in enumerate(str1):
  for (j, y) in enumerate(str2):
   if (x == y):
    matrix[(i + 1)][(j + 1)] = (matrix[i][j] + 1)
   else:
    matrix[(i + 1)][(j + 1)] = max(matrix[(i + 1)][j], matrix[i][(j + 1)])
 return matrix

def build_lengths_matrix ( str1 , str2 ) : matrix = [ [ 0 for j in range ( ( len ( str2 ) + 1 ) ) ] for i in range ( ( len ( str1 ) + 1 ) ) ] for ( i , x ) in enumerate ( str1 ) : for ( j , y ) in enumerate ( str2 ) : if ( x == y ) : matrix [ ( i + 1 ) ] [ ( j + 1 ) ] = ( matrix [ i ] [ j ] + 1 ) else : matrix [ ( i + 1 ) ] [ ( j + 1 ) ] = max ( matrix [ ( i + 1 ) ] [ j ] , matrix [ i ] [ ( j + 1 ) ] ) return matrix
xxx: needs documentation written .