<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def solve(expected: List[Tuple[float, float]], actual: List[Tuple[float, float]]) -> np.ndarray: """ Takes two lists of 3 x-y points each, and calculates the matrix representing the transformation from one space to the other. The 3x3 matrix returned by this method represents the 2-D transformation matrix from the actual point to the expected point. Example: If the expected points are: [ (1, 1), (2, 2), (1, 2) ] And the actual measured points are: [ (1.1, 1.1), (2.1, 2.1), (1.1, 2.1) ] (in other words, a shift of exaxtly +0.1 in both x and y) Then the resulting transformation matrix T should be: [ 1 0 -0.1 ] [ 0 1 -0.1 ] [ 0 0 1 ] Then, if we take a 3x3 matrix B representing one of the measured points on the deck: [ 1 0 1.1 ] [ 0 1 2.1 ] [ 0 0 1 ] The B*T will yeild the "actual" point: [ 1 0 1 ] [ 0 1 2 ] [ 0 0 1 ] The return value of this function is the transformation matrix T """

    # Note: input list shape validation is handled by the type checker

    # Turn expected and actual matricies into numpy ndarrays with the last row
    # of [1 1 1] appended, and then take the dot product of the resulting
    # actual matrix with the inverse of the resulting expected matrix.

    # Shape of `expected` and `actual`:
    # [ (x1, y1),
    #   (x2, y2),
    #   (x3, y3) ]
    ex = np.array([
            list(point) + [1]
            for point in expected
        ]).transpose()

    ac = np.array([
            list(point) + [1]
            for point in actual
        ]).transpose()
    # Shape of `ex` and `ac`:
    # [ x1 x2 x3 ]
    # [ y1 y2 y3 ]
    # [  1  1  1 ]

    transform = np.dot(ac, inv(ex))
    # `dot` in numpy is a misnomer. When both arguments are square, N-
    # dimensional arrays, the return type is the result of performing matrix
    # multiplication, rather than the dot-product (so the return here will be
    # a 4x4 matrix)
    return transform