Best shuffle: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: elided the need for a B variable in the function.) |
m (→{{header|REXX}}: further indented a DO loop.) |
||
Line 2,684: | Line 2,684: | ||
x=overlay(y, overlay(a,x, lastpos(y,x)),j+1) /*fast swap of 2 characters*/ |
x=overlay(y, overlay(a,x, lastpos(y,x)),j+1) /*fast swap of 2 characters*/ |
||
end /*j*/ |
end /*j*/ |
||
do k=1 for L; a=substr(x,k,1) /*handle a possible rep. */ |
|||
if a\==substr(ox,k,1) then iterate /*skip non-replications*/ |
|||
if |
if k==L then x=left(x,k-2)a || substr(x,k-1,1) /*last case*/ |
||
else x=left(x,k-1)substr(x,k+1,1)a || substr(x, k+2) |
|||
end /*k*/ |
|||
end /*k*/ |
|||
return x</lang> |
return x</lang> |
||
'''output''' (with a freebie thrown in): |
'''output''' (with a freebie thrown in): |