Recursively generate all permutation
for i in range ( l , r + 1 ) : NEW_LINE INDENT str [ l ] , str [ i ] = str [ i ] , str [ l ] NEW_LINE permute ( str , l + 1 , r ) NEW_LINE str [ l ] , str [ i ] = str [ i ] , str [ l ] NEW_LINE DEDENT