# Problem Description:
The task is to calculate the area of a specific shape formed by two given points on a grid. The shape is essentially a rectangle with two corners removed. The points are given as tuples of their coordinates. The goal is to determine the area of this shape based on the coordinates of the two points.

# Visual Facts:
1. The image shows three examples of grids with two points marked on each grid.
2. Each example has a shape formed by connecting the points with straight lines, creating a modified rectangle.
3. The modified rectangle has two corners removed, forming right-angled triangles with legs of length 1.
4. The coordinates of the points are provided for each example.
5. The grid lines are clearly marked, and the shapes are drawn in orange.

# Visual Patterns:
1. The shape is a rectangle with two corners removed.
2. The height of the rectangle is determined by the vertical distance between the two points, plus one additional unit.
3. The width of the rectangle is determined by the horizontal distance between the two points, plus three additional units.
4. Each removed corner is a right-angled triangle with legs of length 1, which means each triangle has an area of 0.5 square units.
5. The total area of the shape can be calculated by subtracting the area of the two removed triangles from the area of the rectangle.

# Mathematical Formulation:
1. Let the coordinates of the two points be  (x1, y1)  and  (x2, y2) .
2. The height of the rectangle is  |y2 - y1| + 1 .
3. The width of the rectangle is  |x2 - x1| + 1 .
4. The area of the rectangle is  height * width .
5. The area of each removed triangle is 0.5 square units, so the total area to be subtracted is 1 square unit.
6. The final area of the shape is  height * width - 1 .

# 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)+1
    d2 = abs(y1 - y2)+1
    return d1*d2 - 1


# Test Script
def test():
    test_cases = [
        ((2,2),(4,5), 11),
        ((2,1),(5,6), 23),
        ((2,1),(5,2), 7),
        ((5,7),(3,8), 5),
        ((8,4),(7,3), 3),
    ]
    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()