Loop to find athe valid operations required to sort the permutation
for i in range ( 0 , len ( p ) , 4 ) : NEW_LINE INDENT ans . append ( [ p [ i ] , p [ i + 1 ] , p [ i + 2 ] ] ) NEW_LINE ans . append ( p [ i [ + 2 ] , p [ i ] , p [ i + 3 ] ] ) NEW_LINE DEDENT