RRectDelta
Product

Product features · Union area of two rectangles

01

RectDelta puts overlap accounting at the center of rectangle code review, distinguishing a shared area from edges that only touch.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Union area of two rectangles

● ● ●RectDelta●
A concrete starting point · Union area of two rectangles ×
def union_area(first, second):
    if any(type(v) not in (list, tuple) or len(v) != 4 for v in (first, second)):
        raise ValueError("rectangle.container")
    first, second = tuple(first), tuple(second)
    for rectangle in (first, second):
        if len(rectangle) != 4 or any(type(v) is not int for v in rectangle):
            raise ValueError("rectangle.integer")
        x0, y0, x1, y1 = rectangle
        if x0 >= x1 or y0 >= y1:
            raise ValueError("rectangle.bounds")
    a, b, c, d = first
    e, f, g, h = second
    overlap = max(0, min(c, g) - max(a, e)) * max(0, min(d, h) - max(b, f))
    return (c - a) * (d - b) + (g - e) * (h - f) - overlap
✳Compute the union area of two axis-aligned rectangles with strictly increasing integer bounds.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗