HHullspring
Product

Product features · Integer convex hulls

01

Use convex_hull.py to examine which collinear points disappear from the boundary of a convex hull.

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.

Integer convex hulls

● ● ●Hullspring●
A concrete starting point · Integer convex hulls ×
def convex_hull(points):
    if type(points) is not list or len(points) > 1000:
        raise ValueError("hull.input")
    if any(type(p) not in (tuple, list) or len(p) != 2 or
           any(type(v) is not int for v in p) for p in points):
        raise ValueError("hull.point")
    ordered = sorted(set(map(tuple, points)))
    if len(ordered) <= 1:
        return ordered
    def turn(a,b,c):
        return (b[0]-a[0])*(c[1]-a[1])-(b[1]-a[1])*(c[0]-a[0])
    def chain(sequence):
        out = []
        for p in sequence:
            while len(out) >= 2 and turn(out[-2],out[-1],p) <= 0:
                out.pop()
            out.append(p)
        return out
    return chain(ordered)[:-1]+chain(reversed(ordered))[:-1]
✳Integer convex hulls
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗