# Problem Description
The problem involves working with seven-segment displays and logical XOR operations. Given a sequence of numbers, we need to determine how many segments would be illuminated (shown in red) after performing a logical XOR operation on the segment patterns of all input numbers. The result should count the segments that are different between the input numbers in their seven-segment display representation.

# Visual Facts
1. Each example shows digital numbers in seven-segment display format.
2. The displays use standard seven-segment representation where each digit is formed by up to 7 segments.
3. Each example demonstrates XOR operations between 2-3 different digits.
4. Results are shown with red segments indicating the segments that differ between the operands.
5. Four different examples are provided:
   - 0 XOR 1 results in 4 red segments.
   - 5 XOR 3 results in 2 red segments.
   - 2 XOR 6 XOR 4 results in 1 red segment.
   - 1 XOR 4 XOR 9 results in 4 red segments.

# Visual Patterns
1. Logical Pattern:
   - The red segments in the result represent segments that are different between the input numbers.
   - This is effectively a bitwise XOR operation on the segment patterns.

2. Segment Differentiation:
   - Result segments can only be present if they differ between the input numbers.
   - The number of red segments is the count of segments that are different between the input numbers.

3. Multiple Input Handling:
   - The operation can handle 2 or more input numbers.
   - When more numbers are involved, the XOR operation is applied cumulatively.

4. Segment Rules:
   - The logical XOR operation is applied segment-by-segment.
   - Each segment is treated independently.
   - A segment will be red if it is different between the input numbers.

# Solution
from typing import List

def solution(numbers: List[int]) -> int:
    """
    Given a sequence of numbers, determine the number of red segments that would be illuminated.

    Parameters:
        numbers (List[int]): A list of integers

    Returns:
        int: The total number of segments that will turn red based on the combination of the input numbers.
    """
    segment_map = {
        0: 0b0111111,
        1: 0b0000110,
        2: 0b1011011,
        3: 0b1001111,
        4: 0b1100110,
        5: 0b1101101,
        6: 0b1111101,
        7: 0b0000111,
        8: 0b1111111,
        9: 0b1101111
    }

    if not numbers:
        return 0

    result = 0b0000000

    for number in numbers:
        result ^= segment_map[number]

    red_blocks = bin(result).count('1')

    return red_blocks


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

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

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

test()