This was my effort:
perl -pe
's|(\w)(\w+)(?=\w)|$1.join"",sort{rand 2}split//,$2|ge'
12345678901234567890123456789012345678901234567890123
10 20 30 40 50
Edit:
perl -pe
's|\B(\w+)\B|join"",sort{rand 2}split//,$1|ge'
The golf has more perceptually random results than the other variants posted here which are shorted than it. It doesn't have an even distibution of results tho; words longer than 5 characters have certain permiatations which are more likely to come up. There's an example in the <readmore>.
Permiatations of the world "abcdef", and the likelyhood based on testing of it occuring rounded to fractions:
abcdef: 1/ 8
abcedf: 1/ 8
acbdef: 1/ 8
acbedf: 1/ 8
adbcef: 1/32
adbecf: 1/32
adcbef: 1/32
adcebf: 1/32
adebcf: 1/16
adecbf: 1/16
aebcdf: 1/32
aebdcf: 1/32
aecbdf: 1/32
aecdbf: 1/32
aedbcf: 1/16
aedcbf: 1/16
xxx
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|