# Problem Description
The problem involves determining how many rats a cat can catch based on their positions in a linear sequence.   The cat has a specific position, and there are multiple rats positioned at different indices.   The cat can catch rats who are not in a certain range, called the "captureable Distance," which is calculated as the floor value of half the number of rats.   The task is to implement a function that takes the cat's position and the list of rat positions and returns the number of rats the cat can catch.

# Visual Facts
1.   **Example 1**:
- Cat position: 5
- Rat positions: [0, 1, 6, 7, 10]
- Number of rats: 5
- Captureable Distance: ⌊5 / 2⌋ = 2
- Rats caught: 3 (positions 6, 7, and 10)

2.   **Example 2**:
- Cat position: 5
- Rat positions: [0, 1, 6, 7, 8, 10]
- Number of rats: 6
- Captureable Distance: ⌊6 / 2⌋ = 3
- Rats caught: 2 (positions 6 and 7)

# Visual Patterns
1.   **Captureable Distance Calculation**:
- The captureable Distance is calculated as the floor value of half the number of rats: `captureable_distance = ⌊number of rats / 2⌋`.

2.   **Range of Capture**:
- The cat can catch all the rats who are not in the range of `[cat_position - captureable_distance, cat_position + captureable_distance]`.

3.   **Counting Captured Rats**:
- For each rat, check if its position falls within the capture range.   If it does, it is considered caught.


# Solution
from typing import List

def solution(cat: int, rats: List[int]) -> int:
    """
    Given a cat's position and a list of rats positions, returns the number of rats the cat can catch.

    Parameters:
        cat (int): The position index of the cat (0-based)
        rats (List[int]): List of position indices for the rats (0-based)

    Returns:
        int: Number of rats that can be caught by the cat
    """
    cap_radius = int(len(rats) / 2)
    left_bound = cat - cap_radius
    right_bound = cat + cap_radius
    count = 0
    for i in rats:
        if i < left_bound or i > right_bound:
            count += 1
    return count


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

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

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

test()