Best shuffle: Difference between revisions

Content added Content deleted
m (→‎{{header|D}}: Using works with template)
m (→‎{{header|REXX}}: whitespace)
Line 127: Line 127:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX program to find best shuffle (of a character string). */
<lang rexx>
/*REXX program to find best shuffle (of a character string). */


list='tree abracadabra seesaw elk grrrrrr up a'
list='tree abracadabra seesaw elk grrrrrr up a'
Line 142: Line 141:


exit
exit



/*─────────────────────────────────────bestShuffle procedure────────────*/
/*─────────────────────────────────────bestShuffle procedure────────────*/
Line 168: Line 166:


return x
return x



/*─────────────────────────────────────countSame procedure──────────────*/
/*─────────────────────────────────────countSame procedure──────────────*/
Line 175: Line 172:
k=k+(substr(x,j,1)==substr(y,j,1))
k=k+(substr(x,j,1)==substr(y,j,1))
end
end
return k
return k</lang>
</lang>
Output (with a freebie thrown in):
Output (with a freebie thrown in):
<pre>
<pre style="height:20ex;overflow:scroll">
original: tree new: eert count: 0
original: tree new: eert count: 0
original: abracadabra new: baaracadrab count: 0
original: abracadabra new: baaracadrab count: 0