# Problem Description
This problem involves determining the relationship between two points on a coordinate grid based on their respective layers. The grid is divided into layers, with each layer forming a square perimeter around the origin. The relationship between the points can be one of three types:
- "A": Points are on the same layer.
- "B": Points are on adjacent layers.
- "C": Points are on non-adjacent layers.

Given two points, the task is to determine which of these three relationships they fall into.

# Visual Facts
1. The coordinate system has both x and y axes starting from 0.
2. Points are organized into layers labeled L0, L1, L2, L3, etc.
3. Three types of relationships are illustrated:
   - "A": Same Layer (orange arrows)
   - "B": Adjacent Layer (green arrows)
   - "C": Non-Adjacent Layer (red arrows)
4. Layer 0 (L0) includes points where either x or y is 0.
5. Layer 1 (L1) includes points where either x or y is 1.
6. Layer 2 (L2) includes points where either x or y is 2.
7. Layer 3 (L3) includes points where either x or y is 3.
8. Each layer forms a square perimeter around the origin.
9. The maximum layer shown is L3.
10. Points only exist at integer coordinates.

# Visual Patterns
1. **Layer Determination Pattern**:
   - A point's layer number is determined by the minimum of its x and y coordinates.
   - For any point (x, y), its layer = min(x, y).

2. **Relationship Classification Rules**:
   - "A": Points are on the same layer.
     - Example: Two points both on L3.
   - "B": Points are on consecutive layers.
     - Example: One point on L2 and another on L3.
   - "C": Points are separated by at least one layer.
     - Example: One point on L1 and another on L3.

# Solution
from typing import Tuple

def layer(x: int, y: int) -> int:
    """
    Determine the layer of a point based on its coordinates.

    Parameters:
        x (int): The x-coordinate of the point.
        y (int): The y-coordinate of the point.

    Returns:
        int: The layer of the point.
    """
    return min(x, y)

def solution(point1: Tuple[int, int], point2: Tuple[int, int]) -> str:
    """
    Determine the relationship between two points based on their layers.
    
    Parameters:
        point1 (Tuple[int, int]): The coordinates of the first point, where both x and y are non-negative integers.
        point2 (Tuple[int, int]): The coordinates of the second point, where both x and y are non-negative integers.
    
    Returns:
        str: Return 'A', 'B'. 'C'.
    """

    x1, y1 = point1
    x2, y2 = point2
    layer1 = layer(x1, y1)
    layer2 = layer(x2, y2)
    if layer1 == layer2:
        return 'A'
    if abs(layer1 - layer2) == 1:
        return 'B'
    return 'C'


# Test Script
def test():
    test_cases = [
        ((2, 0), (2, 1), 'B'),
        ((0, 0), (4, 0), 'A'),
        ((1, 0), (2, 0), 'A'),
        ((0, 0), (0, 0), 'A'),
        ((3, 10), (4, 4), 'B'),
        ((5, 6), (7, 4), 'B'),
        ((9, 9), (9, 10), 'A'),
        ((999, 1002), (1000, 1000), 'B'),
        ((0, 0), (0, 1), 'A'),
        ((0, 0), (1, 0), 'A'),
        ((0, 0), (2, 2), 'C'),
        ((7, 4), (7, 2), 'C'),
        ((9, 2), (4, 8), 'C')
    ]
    for point1, point2, expected_output in test_cases:
        try:
            output = solution(point1, point2)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`point1`: {point1}\n"
                f"`point2`: {point2}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message

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

test()