I would like to get all permutations of the replaced pairs of string characters. For instance:
Base line: abcd
Combinations:
and etc.
Edit
I want to change only the letters that are next to each other. Like the first with the second, the second with the third, but not the third with a pole.
What is the best way to do this?
Edit
Just for fun: there are three or four solutions, could anyone post a speed test for those so we can compare which is faster?
Speed test
I did a speed test on nickf and mine, and the results are that mine beats nick with four letters (0.08 and 0.06 for 10K times), but nickf beats it with 10 letters (nick 0.24 and mine 0.37)
source
share