Open the context
Choose the project folder and name the files or behavior involved.
Generate a Collatz trajectory from a positive integer under explicit step and value caps. Test a start of one, a sequence reaching one and both caps being exceeded, raising an error rather than claiming every sequence terminates.
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 collatz(start, max_steps, value_cap):
if any(type(v) is not int for v in (start, max_steps, value_cap)):
raise ValueError("limit.integer")
if not 0 <= max_steps <= 10000 or not 1 <= start <= value_cap <= 10**18:
raise ValueError("limit.range")
result = [start]
for _ in range(max_steps):
if start == 1:
return result
start = start // 2 if start % 2 == 0 else 3 * start + 1
if start > value_cap:
raise ValueError("value.cap")
result.append(start)
if start != 1:
raise ValueError("step.cap")
return resultThe 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.