WWindowRidge
AI coding workspace

Sliding-window maxima

The next window reuses most of the last one. WindowRidge connects a sliding calculation, its boundary cases and a reviewable implementation inside a Windows coding client.

● ● ●WindowRidge●
A concrete starting point · Sliding-window maxima ×
from collections import deque
from math import isfinite
def window_max(values, width):
    if type(width) is not int or not 1 <= width <= len(values):
        raise ValueError("width")
    if not all(map(isfinite, values)): raise ValueError("finite values")
    queue, result = deque(), []
    for i, value in enumerate(values):
        while queue and queue[0] <= i - width: queue.popleft()
        while queue and values[queue[-1]] <= value: queue.pop()
        queue.append(i)
        if i >= width - 1: result.append(values[queue[0]])
    return result
✳Find the maximum in each complete fixed-width numeric window.
✓ ChangesReview before applying ↗
Illustrative workspace
Review before applyingCompare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
ConnectionBase URL, credentials and a reachable server.
ProjectCheck repeated maxima, negative values and width boundaries, rejecting non-finite values and widths outside the input length.
Workflows

Sliding-window maxima

Workflows ↗
A concrete starting point
from collections import deque
from math import isfinite
def window_max(values, width):
    if type(width) is not int or not 1 <= width <= len(values):
        raise ValueError("width")
    if not all(map(isfinite, values)): raise ValueError("finite values")
    queue, result = deque(), []
    for i, value in enumerate(values):
        while queue and queue[0] <= i - width: queue.popleft()
        while queue and values[queue[-1]] <= value: queue.pop()
        queue.append(i)
        if i >= width - 1: result.append(values[queue[0]])
    return result
AI coding workspace

Keep a calculation change connected to its output

WindowRidge is a Windows AI coding workspace for discussing changes in the context of the project that will use them. Start with the output your application expects and identify the source that produces it. Ask the connected model to inspect the current path before proposing a replacement, so implementation details stay tied to a visible requirement.

A fixed-width maximum calculation is one useful task. Specify that each result corresponds to a complete window, and include the caller that associates results with input positions. Discuss repeated maxima, negative values and valid width boundaries before requesting an edit. That gives the review a contract beyond obtaining the largest number in a short sample.

Use your project's tests to compare proposed output with explicit fixtures. Check result count and alignment as well as values, including a width of one and a width equal to the input length. If the change is intended to improve efficiency, measure it in your own workload rather than infer a speed guarantee from a different implementation.

Connect a supported OpenAI-compatible or Anthropic endpoint to choose the model for WindowRidge. An unrestricted AI model may be available through that provider, with credentials where required. Model behavior, context capacity and tool support depend on the actual connection; accepting a calculation change still requires your review and verification.

Planning a windowed-calculation patch

Why show the output consumer as well as the routine?

A consumer may associate each value with a particular input position. An edit can preserve maxima while shifting that association. Include the caller and define which window each output represents so the review covers alignment as well as arithmetic.

Which width cases belong in a small fixture set?

Use one, the full input length and an invalid width, alongside the ordinary case your application needs. State the rejection policy for invalid values. Verify both the values and the number of results using your existing project checks.

How can I assess an efficiency-related suggestion?

First confirm equivalent behavior on your fixtures. Then measure the candidate with representative data and your own tooling. A model's explanation of an approach is useful review context, but it is not evidence of performance in your application.

Do repeated maxima need special attention?

Include them because an implementation may track candidate positions as well as values. Ask for an explanation of how old candidates leave the window, then compare the proposed behavior against an explicit expected sequence before accepting the patch.

Get the Windows app ↗

WindowRidge · Updated 2026-10-25