NNimClover
Workflows

Coding workflows · Normal-play Nim moves

03
Built around your work

A concrete starting point

Choose a winning reduction for normal-play Nim from at most 128 piles of zero through one billion objects. Test all-zero and losing positions, returning no move when the xor is zero and rejecting negative or Boolean pile sizes.

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.

Normal-play Nim moves

A concrete starting point
def nim_move(piles):
    if type(piles) not in (list, tuple) or len(piles) > 128 or any(type(v) is not int or not 0 <= v <= 10**9 for v in piles):
        raise ValueError("nim.piles")
    balance = 0
    for pile in piles:
        balance ^= pile
    if balance == 0:
        return None
    for index, pile in enumerate(piles):
        reduced = pile ^ balance
        if reduced < pile:
            return index, reduced

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 ↗