Anonymous user
Best shuffle: Difference between revisions
m
→{{header|AWK}}: Change one paragraph.
(→{{header|C}}: Add AWK.) |
m (→{{header|AWK}}: Change one paragraph.) |
||
Line 18:
The equivalent programs for [[#Perl 6|Perl 6]] and for [[#Ruby|Ruby]] use several built-in array functions. But if those array functions seem strange to you, and if you can understand this bunch of for loops, then you might prefer this Awk program.
This algorithm calculates an order of positions, then fills a new string in this order, by moving each letter from the original string. It will never replace an old letter with an identical letter, unless the remainder of the original string has only this letter. The next position
<lang awk># out["string"] = best shuffle of string _s_
|