# Problem Description
This is a coordinate-based zone coloring problem where we need to determine the color of a point given its (x,y) coordinates. The plane is divided into alternating black and white circular rings, with special rules. The coloring pattern depends on:
1. The distance from the origin (0,0)
2. Whether the point lies on a border

# Visual Facts
1. Coordinate System:
   - X-axis ranges from 0 to 5 (visible portion)
   - Y-axis ranges from 0 to 5 (visible portion)
   - Grid is marked in unit intervals

2. Sample Points Given:
   - (1, 2): White zone
   - (3, 2): Black zone
   - (0.5, 0.5): White zone
   - (5, 2): Black zone
   - (2, 0): Border

3. Visual Structure:
   - Concentric circles centered at origin (0,0)
   - Circles are spaced at unit intervals
   - Pattern alternates between black and white rings

# Visual Patterns
1. Distance-Based Rules:
   - Each ring represents a unit distance from the origin
   - The pattern alternates at every integer distance

2. Specific Rules:
   * Even distance → White
   * Odd distance → Black

3. Border Detection:
   - Points exactly on integer distances from origin are borders
   - Border points return value 3

4. Mathematical Patterns:
   - Color determination requires:
     * Calculating distance from origin: √(x² + y²)
     * Checking if point is on border
     * Applying quadrant-specific even/odd rules using the lower bound of distance


# Solution
from typing import Tuple
import math

def solution(coordinate: Tuple[int, int]) -> int:
    """
    Determines the color of the zone at the given coordinate.
    The colors follow an infinitely repeating pattern.

    Args:
        coordinate: A tuple (x, y) representing the coordinate point

    Returns:
        0 for white
        1 for black
        3 for boarder
    """
    x, y = coordinate
    sq = math.sqrt(x*x + y*y)
    if int(sq) == sq:
        return 3
    
    r_floor = math.floor(sq)
    if x > 0 and y > 0:
        quadrant = 1
    elif x < 0 and y > 0:
        quadrant = 2
    elif x < 0 and y < 0:
        quadrant = 3
    elif x > 0 and y < 0:
        quadrant = 4
    else:
        quadrant = 1
    
    if quadrant in [1, 3]:
        return 0 if (r_floor % 2 == 0) else 1
    else:
        return 1 if (r_floor % 2 == 0) else 0


# Test Script
def test():
    test_cases = [
        ((0.5, 0.5), 0),  
        ((0.5, 1.5),1),
        ((3, 2), 1),
        ((1, 1), 1),
        ((5, 3), 1),
        ((5, 4), 0),
        ((2, 2), 0),
        ((4, 3), 3),
        ((7, 7), 1),
        ((23009853, 23009853), 0),
        ((23009853, 23009853), 0),
        ((992384, 223), 0)
    ]

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

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

test()