# Problem Description
This is a geometric area calculation problem where:
- Input consists of two points on a grid system
- These points define a special shape that resembles a rectangle with cut-off corners
- The goal is to calculate the area of this shape based on the given points
- The grid system has positive integer coordinates
- Each point in input tuple represents (x, y) coordinates

# Visual Facts
1. Grid Structure:
   - Each example shows a coordinate grid
   - X-axis increases downward
   - Y-axis increases rightward
   - Grid points are at integer coordinates

2. Point Representation:
   - Blue dots represent the input points
   - Example 1: P1(2,2), P2(4,5)
   - Example 2: P1(5,1), P2(2,6)
   - Example 3: P1(2,1), P2(2,2)

3. Shape Characteristics:
   - Orange lines form an octagonal shape
   - Each corner has a 45-degree cut
   - The cuts are consistent across all examples
   - The shape always connects the two points

# Visual Patterns
1. Shape Formation Rules:
   - The shape forms a modified rectangle between the two points
   - Each corner is cut off with a 1×1 right triangle
   - The cuts are always inward-facing
   - The shape maintains symmetry

2. Dimensional Patterns:
   - Width = |x2-x1| + 3 (including extensions beyond points)
   - Height = |y2-y1| + 1
   - Each corner cut removes an area of 0.5 square units
   - Total corner cuts = 4 × 0.5 = 2 square units

3. Area Calculation Pattern:
   - Base area = (width × height)
   - Final area = Base area - 2 (corner cuts)


# Solution
from typing import Tuple

def solution(p1: Tuple[int, int], p2: Tuple[int, int]) -> int:
    """
    Calculates the area defined by two points according to the specified rules in the image.

    Parameters:
        p1 (Tuple[int, int]): Coordinates of the first point.
        p2 (Tuple[int, int]): Coordinates of the second point.

    Returns:
        int: The calculated area defined by the two points.
    """
    x1, y1 = p1
    x2, y2 = p2
    d1 = abs(x1 - x2)+3
    d2 = abs(y1 - y2)+1
    return d1*d2 -2


# Test Script
def test():
    test_cases = [
        ((2,2),(4,5), 18),
        ((2,1),(5,6), 34),
        ((2,1),(5,2), 10),
        ((5,7),(3,8), 8),
        ((8,4),(7,3), 6),
    ]
    for p1, p2, expected_output in test_cases:
        try:
            output = solution(p1, p2)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`p1`: {p1}\n" 
                f"`p2`: {p2}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message

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

test()