Best shuffle: Difference between revisions
m
→{{header|Raku}}: use 'X' to avoid a nested loop
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: use 'X' to avoid a nested loop) |
||
Line 3,972:
(formerly Perl 6)
{{trans|Sidef}}
<syntaxhighlight lang=raku line>sub best-shuffle(Str $orig) {
my @s = $orig.comb;
my @t = @s.pick(*);
for flat ^@s X ^@s ->
}
}
Line 3,993 ⟶ 3,988:
}
}
printf "%s, %s, (%d)\n", $_, best-shuffle $_ for <abracadabra seesaw elk grrrrrr up a>;</syntaxhighlight>
{{out}}
<pre>abracadabra, raacarabadb, (0)▼
▲abracadabra, raacarabadb, (0)
seesaw, wssaee, (0)
elk, lke, (0)
grrrrrr, rrrgrrr, (5)
up, pu, (0)
a, a, (1)</pre>
=={{header|Rascal}}==
|