# Problem Description
The problem involves working with seven-segment displays and logical AND operations. Given a sequence of numbers, we need to determine how many segments would be illuminated (shown in red) after performing a logical AND operation on the segment patterns of all input numbers. The result should count the segments that are common to all 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 AND operations between 2-3 different digits
4. Results are shown with red segments indicating the common segments between all operands
5. Four different examples are provided:
   - 8 & 1 results in 2 red segments
   - 5 & 3 results in 4 red segments
   - 2 & 6 & 4 results in 1 red segment
   - 7 & 8 & 9 results in 3 red segments

# Visual Patterns
1. Logical Pattern:
   - The red segments in the result represent segments that are ON (active) in ALL input numbers
   - This is effectively a bitwise AND operation on the segment patterns

2. Segment Conservation:
   - Result segments can only be present if they appear in all input numbers
   - The number of red segments is always less than or equal to the minimum number of segments in any input digit

3. Multiple Input Handling:
   - The operation can handle 2 or more input numbers
   - When more numbers are involved, fewer segments tend to remain common (red)

4. Segment Rules:
   - The logical AND operation is applied segment-by-segment
   - Each segment is treated independently
   - A segment must be present in all input numbers to appear in the result


# 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 = 0b1111111

    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], 2),
        ([3, 5], 4),
        ([5, 3], 4),
        ([2, 3], 4),
        ([4, 5], 3),
        ([6, 7], 2),
        ([8, 9], 6),
        ([2, 6, 4], 1),
        ([7, 8, 9], 3),
        ([1, 2, 3, 4], 1),
        ([5, 6, 7, 8], 2),
        ([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], 0)
    ]

    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()