Maximum contiguous sum
SpanKestrel supports project work where a run of values matters more than an isolated maximum. Use the Windows client to discuss contiguous-sum logic and inspect its treatment of negative data before accepting edits.
def maximum_subarray(values):
if type(values) not in (list, tuple) or len(values) > 1000 or any(type(v) is not int or abs(v) > 10**9 for v in values):
raise ValueError("subarray.input")
if not values:
return None
best = None
total, start = 0, 0
for end, value in enumerate(values, 1):
if total < 0:
total, start = 0, end - 1
total += value
candidate = (total, start, end)
if best is None or (-total, start, end) < (-best[0], best[1], best[2]):
best = candidate
return best- Connection
- Base URL, credentials and a reachable server.
- Project
- Test all-negative and empty input, resolving ties by earliest start then earliest end.
- Review before applying
- Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def maximum_subarray(values):
if type(values) not in (list, tuple) or len(values) > 1000 or any(type(v) is not int or abs(v) > 10**9 for v in values):
raise ValueError("subarray.input")
if not values:
return None
best = None
total, start = 0, 0
for end, value in enumerate(values, 1):
if total < 0:
total, start = 0, end - 1
total += value
candidate = (total, start, end)
if best is None or (-total, start, end) < (-best[0], best[1], best[2]):
best = candidate
return bestMake a selected range useful to its caller
Selecting a range from a sequence involves more than reporting a total. The caller needs to know where that range begins, where it ends and what happens when no values exist. SpanKestrel provides a Windows AI coding workspace for reviewing those decisions alongside your application's files. Describe how the selected range is used before asking the assistant to revise the selection code.
The maximum-contiguous-sum example is a concrete task you could explore. You might examine all-negative input, tied candidates and the convention for the returned end position. Ask the assistant to inspect how the caller slices or highlights the result, then review the proposed edits against that usage. Keep expected ranges in your test cases so a correct total cannot conceal an incorrect boundary.
An uncensored AI model may be chosen through a supported OpenAI-compatible or Anthropic endpoint when available, using credentials if required. Its model and server determine context, tools and restrictions. Run the project's checks after reviewing changes, including empty input and tied results. A local endpoint requires a separate model server and does not automatically keep every connected tool local.
Questions about range results
Should the returned end position include the final value?
State the convention explicitly and inspect the caller's slicing or display code. Either convention needs consistent handling across the boundary. A useful test asserts the selected values as well as the reported positions and total.
What should happen when several ranges have the same total?
Define a stable tie rule if the application depends on one. Include examples where candidates begin or end at different positions. Review the implementation and consuming code together so the chosen result remains predictable to the user.
Is an empty input equivalent to a range totaling zero?
Not necessarily. Your application may distinguish no result from a real range whose values sum to zero. Preserve that distinction in the return contract and check how the caller renders or otherwise acts on each case.
Does SpanKestrel include a built-in sequence analysis report?
The example describes code you can investigate and adapt in your project. No ready-made report is established. Specify any reporting or visualization work separately, review the proposed implementation and test its use of the returned range.
SpanKestrel · Updated 2026-10-25