def spiral_layer(
        top: int,
        bottom: int,
        left: int,
        right: int,
        matrix: list[list[int]],
) -> list[int]:
    """Traverses one layer of the matrix spiral into a list"""
    ans = []
    for col in range(left, right+1):
        ans.append(matrix[top][col])

    for row in range(top+1, bottom):
        ans.append(matrix[row][right])

    for col in range(right, left-1, -1):
        ans.append(matrix[bottom][col])

    for row in range(bottom-1, top, -1):
        ans.append(matrix[row][left])

    return ans