# Problem Description
The task involves manipulating a binary array based on a chosen index. Specifically, given a binary array (containing only 0s and 1s) and a chosen index, the goal is to transform the array such that each element (except the one at the chosen index) is replaced by the result of the XNOR operation between itself and the element at the chosen index. The function should return the modified array.

# Visual Facts
1. The input is a binary array consisting of 0s and 1s.
2. There is a chosen index in the array.
3. The output array is derived by applying the XNOR operation between each element and the element at the chosen index.
4. The element at the chosen index remains unchanged in the output array.

# Visual Patterns
1. **XNOR Operation**: The XNOR operation between two binary digits results in 1 if both digits are the same and 0 if they are different.
   - XNOR(0, 0) = 1
   - XNOR(1, 1) = 1
   - XNOR(0, 1) = 0
   - XNOR(1, 0) = 0

2. **Transformation Rule**:
   - For each element in the array, except the one at the chosen index, replace it with the result of the XNOR operation between itself and the element at the chosen index.
   - The element at the chosen index remains unchanged.

3. **Example Analysis**:
   - **Example 1**:
     - Input Array: [1, 0, 1, 0, 1]
     - Chosen Index: 1 (value = 0)
     - Output Array: [XNOR(1, 0), 0, XNOR(1, 0), XNOR(0, 0), XNOR(1, 0)] = [0, 0, 0, 1, 0]
   - **Example 2**:
     - Input Array: [1, 1, 0, 1, 0, 1]
     - Chosen Index: 3 (value = 1)
     - Output Array: [XNOR(1, 1), XNOR(1, 1), XNOR(0, 1), 1, XNOR(0, 1), XNOR(1, 1)] = [1, 1, 0, 1, 0, 1]

# Solution
from typing import List

def solution(bin_array: List[int], chosen: int) -> List[int]:
    """
    Manipulates a binary array based on the selected index position.

    Parameters:
        bin_array (List[int]): A binary array containing only 0s and 1s
        chosen (int): Zero-based index of the chosen cell

    Returns:
        List[int]: The manipulated binary array
    """
    chosen_value = bin_array[chosen]
    result = []
    for i in range(len(bin_array)):
        if i == chosen:
            result.append(chosen_value)
        else:
            result.append(1-  (bin_array[i] ^ chosen_value))
    return result


# Test Script
def test():
    test_cases = [
        ([1, 1, 0, 1, 0, 1, 0, 1],3 ,[1, 1, 0, 1, 0, 1, 0, 1]),
        ([1, 1, 0, 1, 0, 1, 0, 1],4 ,[0, 0, 1, 0, 0, 0, 1, 0]),
        ([1, 0, 1, 0, 1, 1],1 ,[0, 0, 0, 1, 0, 0]),
        ([0, 0, 0, 0, 0, 0, 1, 0, 0, 0],0 ,[0, 1, 1, 1, 1, 1, 0, 1, 1, 1]),
        ([1, 0, 1, 1, 0, 0, 1, 1],5 ,[0, 1, 0, 0, 1, 0, 0, 0]),
        ([0, 1, 0, 0, 0, 0],1 ,[0, 1, 0, 0, 0, 0]),
        ([1, 1, 1, 0, 1, 0, 0, 0, 1, 0],4 ,[1, 1, 1, 0, 1, 0, 0, 0, 1, 0]),
        ([0, 1, 0, 0, 0, 0],2 ,[1, 0, 0, 1, 1, 1]),
        ([0, 1, 1, 0, 1, 1, 0],1 ,[0, 1, 1, 0, 1, 1, 0]),
        ([0, 0, 1, 0, 0, 0, 0],2 ,[0, 0, 1, 0, 0, 0, 0]),
    ]

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

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

test()