SSpiralJuniper
Workflows

Coding workflows · Clockwise grid spirals

03
Built around your work

A concrete starting point

Visit every coordinate of a rectangular grid in a clockwise spiral starting at the top left. Check zero dimensions and single rows or columns, rejecting dimensions outside zero through 100 and proving each coordinate appears once.

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.

Clockwise grid spirals

A concrete starting point
def spiral(rows, columns):
    if any(type(v) is not int or not 0 <= v <= 100
           for v in (rows, columns)):
        raise ValueError("dimension.range")
    top, bottom, left, right = 0, rows - 1, 0, columns - 1
    result = []
    while top <= bottom and left <= right:
        result.extend((top, c) for c in range(left, right + 1))
        top += 1
        result.extend((r, right) for r in range(top, bottom + 1))
        right -= 1
        if top <= bottom:
            result.extend((bottom, c) for c in range(right, left - 1, -1))
            bottom -= 1
        if left <= right:
            result.extend((r, left) for r in range(bottom, top - 1, -1))
            left += 1
    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 ↗