Check if all 3 indices can be placed to respective correct indices in a single move
if ( arr [ arr [ arr [ i ] ] ] == i and arr [ arr [ i ] ] != i ) : NEW_LINE INDENT temp = arr [ arr [ i ] ] NEW_LINE indices . append ( [ i , arr [ i ] , arr [ arr [ i ] ] ] ) NEW_LINE sw = arr [ i ] NEW_LINE arr [ i ] = arr [ arr [ i ] ] NEW_LINE arr [ sw ] = sw NEW_LINE sw = arr [ i ] NEW_LINE arr [ i ] = arr [ temp ] NEW_LINE arr [ temp ] = sw NEW_LINE DEDENT