Open the context
Choose the project folder and name the files or behavior involved.
Find the first index whose integer value is at least the target in a sorted list. Check duplicates, empty input and insertion after the end, rejecting unsorted or non-integer input before binary search.
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 lower_bound(values, target):
if type(values) is not list or type(target) is not int:
raise ValueError("bound.input")
if any(type(v) is not int for v in values):
raise ValueError("bound.member")
if any(a > b for a,b in zip(values, values[1:])):
raise ValueError("bound.order")
lo, hi = 0, len(values)
while lo < hi:
mid = (lo+hi)//2
if values[mid] < target:
lo = mid+1
else:
hi = mid
return loThe 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.