in reply to Transposition of each letter pair in string
#!/usr/bin/perl -w use strict; $_= "thisisatest"; print "$_:\n"; while( /(.)(?=(.))/g ) { print substr( $_, 0, pos($_)-1 ), $2, $1, substr( $_, pos($_)+1 ), $/; }
Rewording the description in a manner that helped at least one person understand: Take a string, pick any pair of consecutive letters in the string (at random), swap them. What is the list of all possible results?
- tye
|
|---|