RRectDelta
AI coding workspace

Union area of two rectangles

RectDelta offers a project workspace for discussing rectangle arithmetic with AI. Open the relevant folder, inspect how a compatible model handles overlap and review the suggested bounds checks alongside the code.

● ● ●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
  1. Connection

    Base URL, credentials and a reachable server.

  2. Project

    Check overlapping, contained and touching rectangles, rejecting zero-area or reversed bounds before arithmetic and leaving both inputs unchanged.

  3. Review before applying

    Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Workflows

Union area of two rectangles

Workflows ↗
A concrete starting point
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
AI coding workspace

Connect geometry code to the data it receives

RectDelta provides a Windows coding workspace for discussing geometry code as part of an application, including the input boundaries around the calculation. Open the project and describe where the coordinates originate and what the result is used for. Ask the connected assistant to inspect those relationships before proposing a different implementation of the arithmetic.

For a rectangle-union task, specify the coordinate ordering, accepted number type and treatment of shapes that merely touch. Bring contained and overlapping rectangles as example inputs, then discuss how invalid bounds should be reported. Those decisions give the code review a concrete target without turning the illustrative calculation into a claim about a built-in geometry engine.

Review validation and arithmetic together, and run the project's checks with both ordinary and rejected shapes. Confirm that the caller receives the intended result and that inputs remain available unchanged for subsequent work. RectDelta connects to supported OpenAI-compatible or Anthropic services, with credentials when needed. An unrestricted model can be chosen where the configured endpoint offers it; provider rules and server capabilities still govern the connection. Keep the acceptance examples in the conversation so each suggested edit can be judged against the same application requirement.

Geometry contracts before implementation changes

What should I specify about a rectangle input?

State the coordinate order, accepted numeric types and whether both dimensions must be positive. Include how malformed containers should fail. The assistant can then review the complete boundary rather than assume every four-value input describes an acceptable shape.

Why include touching rectangles in fixtures?

They distinguish shared boundaries from positive-area overlap. State the expected union result and test it directly, along with separated and contained cases, so the patch reflects the geometry convention used by the rest of your application.

Can validation change during an arithmetic cleanup?

It can change accidentally, which is why both deserve review. Compare accepted and rejected input cases before keeping the patch. A shorter calculation should not silently admit reversed bounds or number types excluded by your original contract.

How should I check input preservation?

Keep copies of the original coordinate containers and compare them after the call. If later application steps reuse them, a correct area alone is insufficient evidence that the proposed implementation respects the full contract.

Get the Windows app ↗

RectDelta · Updated 2026-10-25