# Problem Description
This is a problem about implementing a custom binary operation on two sequences of integers. The operation involves binary conversions, bitwise OR operations, and addition. Given two sequences of integers, we need to process each sequence independently using binary operations and then combine their results.

# Visual Facts
1. The image shows two examples demonstrating the operation:
   - Example 1: Seq1 = [2,4,2], Seq2 = [3,3,12] → Result = 21
   - Example 2: Seq1 = [4,4,6], Seq2 = [3,1,7] → Result = 13

2. Each sequence gets processed through these steps:
   - Numbers are converted to binary (shown in parentheses)
   - Binary OR operations are performed between all numbers
   - Result is converted back to decimal

3. For Example 1:
   - Seq1: 2(010) OR 4(100) OR 2(010) = 6(110)
   - Seq2: 3(011) OR 3(011) OR 12(1100) = 15(1111)

4. For Example 2:
   - Seq1: 4(100) OR 4(100) OR 6(110) = 6(110)
   - Seq2: 3(011) OR 1(001) OR 7(111) = 7(111)

# Visual Patterns
1. Binary Operation Pattern:
   - Each number in a sequence is converted to binary
   - A bitwise OR operation is applied across all binary numbers in the sequence
   - The result is converted back to decimal

2. Combination Pattern:
   - The decimal results from both sequences are added together
   - Example 1: 6 + 15 = 21
   - Example 2: 6 + 7 = 13

3. Sequence Processing Pattern:
   - Each sequence is processed independently
   - The order of numbers within each sequence doesn't affect the result (due to OR operation properties)
   - The length of both sequences appears to be the same in examples (3 numbers each)

4. Binary Conversion Rules:
   - Numbers are represented in 3 or 4 bits as needed
   - Leading zeros are included in the binary representation where shown
   - The OR operation preserves the maximum number of bits needed for representation


# Solution
from typing import List

def solution(sequence1: List[int], sequence2: List[int]) -> int:
    """
    Applies a custom operation to two integer sequences and returns their combined result.

    Args:
        sequence1: First sequence of integers
        sequence2: Second sequence of integers

    Returns:
        Integer result after applying the operation on both sequences
    """
    # Helper function to calculate OR result for a sequence
    def calculate_or(sequence: List[int]) -> int:
        result = 0
        for num in sequence:
            result |= num  # Perform bitwise OR with the current result
        return result

    # Calculate OR results for both sequences
    result1 = calculate_or(sequence1)
    result2 = calculate_or(sequence2)

    # Return the sum of the two OR results
    return result1 + result2


# Test Script
def test():
    test_cases = [
        {"input": ([2, 4, 3], [3, 3, 12]), "expected": 22},
        {"input": ([4, 5, 6], [3, 1, 7]), "expected": 14},
        {"input": ([1], [2]), "expected": 3},
        {"input": ([0, 0, 0], [0, 0, 0]), "expected": 0},
        {"input": ([8, 16, 32], [7, 3]), "expected": 63}, 
        {"input": ([1, 2, 4, 8], [1, 2, 4, 8]), "expected": 30},
        {"input": ([1, 3, 5, 7], [2, 4, 6, 8]), "expected": 21},
        {"input": ([1, 2, 3, 4, 5], [6, 7, 8, 9, 10]), "expected": 22},
        {"input": ([1, 2, 3, 4, 5], [5, 4, 3, 2, 1]), "expected": 14},
        {"input": ([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]), "expected": 14},
    ]

    for i, test_case in enumerate(test_cases, start=1):
        sequence1, sequence2 = test_case["input"]
        expected_output = test_case["expected"]
        
        try:
            output = solution(sequence1, sequence2)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`sequence1`: {sequence1}\n"
                f"`sequence2`: {sequence2}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message

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

test()