Open the context
Choose the project folder and name the files or behavior involved.
Choose a maximum-size nonoverlapping subset of up to 64 half-open intervals with integer endpoints within ±10^9. Test touching endpoints and tied finishes, rejecting empty-length intervals while preserving the input and returning original indices.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def interval_selection(intervals):
if type(intervals) is not list or len(intervals) > 64:
raise ValueError("schedule.input")
ordered = []
for index, pair in enumerate(intervals):
if type(pair) not in (list, tuple) or len(pair) != 2 or any(type(x) is not int or abs(x) > 10**9 for x in pair):
raise ValueError("schedule.pair")
start, end = pair
if start >= end:
raise ValueError("schedule.interval")
ordered.append((end, start, index))
selected, last = [], None
for end, start, index in sorted(ordered):
if last is None or start >= last:
selected.append(index)
last = end
return selected
The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.