# Problem Description
This is a list transformation problem where we need to implement a special swapping mechanism. Given an input list and a sequence of swap locations, we perform a series of swap operations. Each swap operation starts from the beginning of the list and reverses the portion of the list from index 0 to the given index minus one multiple times. The operation maintains a specific mathematical pattern for determining which elements to swap.

# Visual Facts
1. Input List: [6, 3, 7, 9, 2, 3, 7, 0]
2. Swap Locations: [2, 1, 6, 3]
3. Four distinct steps are shown, each corresponding to a swap location
4. Each step shows:
   - Current state of the list
   - Location where swap starts (marked with red line)
   - Arrows showing element movements
   - Resulting state after the swap
5. List length remains constant at 8
6. All elements are preserved during swaps
7. Red vertical lines mark the end position of each swap
8. Double-headed arrows indicate which elements are being swapped

# Visual Patterns
1. Swap Operation Pattern:
   - For each swap location i, multiple pairs of elements are swapped
   - The swaps "mirror" elements around the middle of the remaining sublist
   - Elements between position 0 and position i - 1 get reversed

2. Mathematical Pattern for Swaps:
   - For swap location i:
     * First pair: swap(0, i-1)
     * Second pair: swap(1, i-2)
     * Third pair: swap(2, i-3)
     * Continue until reaching middle


# Solution
from typing import List

def solution(l: List[int], swap_locations: List[int]) -> List[int]:
    """
    Modifies a list by swapping elements according to the specified swap locations.

    Parameters:
        l (List[int]): The input list to be modified
        swap_locations (List[int]): A list of indices indicating where elements should be swapped

    Returns:
        List[int]: The modified list after performing the swaps.
    """
    for loc in swap_locations:
        l = l[:loc][::-1] + l[loc:]
        
    return l


# Test Script
def test():
    test_cases = [
        ([10, 20, 30, 40, 50], [2, 3], [30, 10, 20, 40, 50]),
        ([5, 15, 25, 35, 45, 55], [1, 4], [35, 25, 15, 5, 45, 55]),
        ([7, 14, 21, 28, 35, 42, 49], [2, 5, 3], [21, 28, 35, 7, 14, 42, 49]),
        ([8, 16, 24, 32, 40, 48, 56, 64], [6, 2], [40, 48, 32, 24, 16, 8, 56, 64]),
        ([1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [4, 7, 2], [11, 13, 9, 1, 3, 5, 7, 15, 17, 19]),
        ([99, 88, 77, 66, 55, 44, 33, 22, 11], [3, 6, 0], [44, 55, 66, 99, 88, 77, 33, 22, 11]),
        ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [9, 0, 5], [5, 6, 7, 8, 9, 4, 3, 2, 1, 10]),
        ([100, 200, 300, 400, 500], [1, 3, 0], [300, 200, 100, 400, 500]),
        ([9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [4, 2, 7, 1], [3, 4, 5, 9, 8, 6, 7, 2, 1, 0]),
        ([1, 4, 9, 16, 25, 36, 49, 64, 81, 100], [2, 4, 6, 8], [64, 49, 16, 9, 1, 4, 25, 36, 81, 100])
    ]

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

        if output != expected_output:
            error_message = (
                f"The following Test Case failed:\n"
                f"`l`: {l}\n"
                f"`swap_locations`: {swap_locations}\n\n"
                f"Actual Output: {output}\n"
                f"Expected Output: {expected_output}"
            )
            assert False, error_message

test()