Implement a function in Python to assign t-shirts of various sizes to a list of participants based on their preferred sizes. The function needs to allocate available t-shirts while trying to honor the participants' size preferences. If the preferred size is unavailable, the function should attempt to assign a t-shirt of the next closest size, either larger or smaller. If no suitable t-shirt is available, an error should be raised.
Functionality Requirements:
Your function should be named assign_t_shirts.
It should accept two parameters:
t_shirt_counts: A list of integers representing the available counts of t-shirts for sizes ['S', 'M', 'L', 'XL', 'XXL'] where:
t_shirt_counts[0] = number for size 'S'
t_shirt_counts[1] = number for size 'M'
t_shirt_counts[2] = number for size 'L'
t_shirt_counts[3] = number for size 'XL'
t_shirt_counts[4] = number for size 'XXL'
participants: A list of strings representing the preferred sizes of each participant. Each size must be one of the valid size labels ['S', 'M', 'L', 'XL', 'XXL'].
Your function should return a list of assigned t-shirt sizes for each participant, maintaining their order. If a participant cannot be assigned a t-shirt due to all sizes being unavailable, the function should raise a ValueError with the message "No T-shirt available for participant".