OOrbitCress
Workflows

Coding workflows · Bounded Collatz trajectories

03
Built around your work

A concrete starting point

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.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Bounded Collatz trajectories

A concrete starting point
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 result

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.

AI coding workspace

Your next change starts here.

Get the Windows app ↗