Your result

kody
Join Kody

Untangle the array

Change activity
Array indexes and swaps

Untangle the array

Goal

Sort all six values in at most 5 swaps. Every value starts in the wrong position.

Preview board

Not run

Add instructions, then run your pseudocode.

Repair mission

1 edit available

Run or step through the broken pseudocode. Replace one line to reach the goal.

Pseudocode

0 / 5 instructions

    Ready to run.
    How it works
    Array indexes and swaps

    Track values separately from their array positions.

    Key rule

    Positions start at 1 in this simulator. SWAP exchanges two existing positions and preserves the values.

    Worked example
    Different example: [3,1,2] becomes [1,3,2] after SWAP(1,2). Compare each neighboring pair to check order.
    Win condition

    Complete the pseudocode and concept check.

    Show a hint

    Track positions after every swap. A number may move more than once.

    Related modules
    Edit text

    Enter one instruction per line. You can use the displayed pseudocode or commands from the reference.

    Command reference

    Return to Tower level 2

    WELCOME TO KODY

    A little play. A lot of possibility.

    I’m Kody, your coding companion. Your adventure is ready. Let’s find our way around.

    Log in