def edit_distance(list1, list2):
    """
    Find the minimum number of insertions, deletions, or replacements required
    to turn list1 into list2, using the typical dynamic programming algorithm.

    >>> edit_distance('test', 'test')
    0
    >>> edit_distance([], [])
    0
    >>> edit_distance('test', 'toast')
    2
    >>> edit_distance(['T', 'EH1', 'S', 'T'], ['T', 'OH1', 'S', 'T'])
    1
    >>> edit_distance('xxxx', 'yyyyyyyy')
    8
    """
    m = len(list1)
    n = len(list2)
    data = [[0 for col in range(n+1)] for row in range(m+1)]
    for col in range(n+1):
        data[0][col] = col
    for row in range(m+1):
        data[row][0] = row
    for a in range(1, m+1):
        for b in range(1, n+1):
            if list1[a-1] == list2[b-1]:
                data[a][b] = data[a-1][b-1]
            else:
                data[a][b] = 1 + min(data[a-1][b], data[a][b-1], data[a-1][b-1])
    return data[m][n]