# Problem Description
The task involves manipulating a binary array based on a chosen index. The manipulation is performed by applying a Multiply operation between the chosen element and every other element in the array. The result of this operation is stored in a new output array, where each element is the result of the multiply operation between the chosen element and the corresponding element in the input array. The chosen element itself remains unchanged in the output array.

# Visual Facts
1. The input array contains binary elements (0s and 1s).
2. A specific element in the array is chosen, indicated by the "CHOSEN" label.
3. The output array is generated by performing a Multiply operation between the chosen element and each element in the input array.
4. The chosen element's value is directly copied to the corresponding position in the output array.
5. The length of the output array is the same as the input array.

# Visual Patterns
1. If the chosen element is 0, all elements except the chosen element in the output array become 0. This is because any number Multiply 0 results in 0.
2. If the chosen element is 1, the output array elements except the chosen element remain the same value.
3. The chosen element's value is directly copied to the corresponding position in the output array without any change.
4. The operation is applied uniformly across all elements in the array.

# 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(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, 0, 0, 0, 0, 0, 0]),
        ([1, 0, 1, 0, 1, 1],1,[0, 0, 0, 0, 0, 0]),
        ([0, 0, 0, 0, 0, 0, 1, 0, 0, 0],0,[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
        ([1, 0, 1, 1, 0, 0, 1, 1],5,[0, 0, 0, 0, 0, 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,[0, 0, 0, 0, 0, 0]),
        ([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()