# Problem Description
This is a array transformation problem where we need to simulate the removal of elements from both ends of an array over time. Given an initial array at T=0, we need to return the state of the array at a specified time point T. The transformation occurs by removing one element from each end (leftmost and rightmost) of the array at each time step.

# Visual Facts
1. Example 1 shows:
   - Initial array (T=0): [3, -1, 0, 2, -9, -7]
   - At T=1: [-1, 0, 2, -9]
   - At T=2: [0, 2]
   - At T=3: [] (empty array)

2. Example 2 shows:
   - Initial array (T=0): [3, -4, -2, 4, -6, -5, 3, -2, 7]
   - At T=1: [-4, -2, 4, -6, -5, 3, -2]
   - At T=2: [-2, 4, -6, -5, 3]
   - At T=3: [4, -6, -5]
   - At T=4: [-6]
   - At T=5: [] (empty array)

# Visual Patterns
1. Array Size Pattern:
   - At each time step, the array size decreases by 2
   - If initial array has n elements:
     - At T=1: n-2 elements
     - At T=2: n-4 elements
     - At T=k: n-2k elements

2. End Condition Pattern:
   - The process continues until the array becomes empty
   - For odd-length initial arrays, the last non-empty state will have 1 element
   - For even-length initial arrays, the last non-empty state will have 2 elements

3. Validity Pattern:
   - T cannot be negative
   - If T is greater than or equal to ceil(n/2), the result is an empty array
   - Maximum valid T = ceil(n/2) where n is the initial array length

4. Element Selection Pattern:
   - At each step T, remove one element from each end
   - Remaining elements maintain their relative positions
   - No reordering or modification of remaining elements occurs


# Solution
from typing import List

def solution(nums: List[int], T: int) -> List[int]:
    """
    Returns the array at a specified time point T.

    Parameters:
        nums (List[int]): The initial array of integers        
        T (int): The target time point

    Returns:
        List[int]: The array at time T
    """
    len_num = len(nums)
    if len_num  - T*2 <= 0:
        return []

    return nums[T:len_num - T]


# Test Script
def test():
    test_cases = [
        ([3,-1,0,2,-9,-7],2, [0,2]),
        ([3,-4,-2,4,-6,-5,3,-2,7], 3,[4,-6,-5]),
        ([3,-4,-2,4,-6,-5,3,-2,7], 0,[3,-4,-2,4,-6,-5,3,-2,7]),
        ([3,-4,-2,4,-6,-5,3,-2,7], 1,[-4,-2,4,-6,-5,3,-2]),
        ([3,-4,-2,4,-6,-5,3,-2,7], 2,[-2,4,-6,-5,3]),
        ([59,65,21,87,37],4,[]),
        ([136, 839, 614, 172, 834, 661, 751, 474, 352, 161], 4, [834, 661]),
        ([125, 132, 147, 725, 597, 492, 258], 3, [725]),
        ([103, 706, 283, 830, 358, 528, 67, 587, 940], 1, [706, 283, 830, 358, 528, 67, 587]),
        ([821, 287, 970, 212], 1,[287, 970]),
        
    ]
    def equal_arr(arr1, arr2):
        if len(arr1) != len(arr2):
            return False
        for num1, num2 in zip(arr1, arr2):
            if num1 != num2:
                return False
        return True

    for nums, T, expected_output in test_cases:
        try:
            output = solution(nums, T)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`nums`: {nums}\n"
                f"`T`: {T}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message

        if not equal_arr(output, expected_output):
            error_message = (
                f"The following Test Case failed:\n"
                f"`nums`: {nums}\n" 
                f"`T`: {T}\n\n"
                f"Actual Output: {output}\n"
                f"Expected Output: {expected_output}"
            )
            assert False, error_message

test()