Anonymous user
Best shuffle: Difference between revisions
→{{header|D}}: more concise
(→Swap if it is locally better algorithm: Shortened output) |
(→{{header|D}}: more concise) |
||
Line 631:
<lang d>import std.stdio, std.random, std.algorithm, std.conv, std.range, std.typecons;
auto bestShuffle(in dstring
auto
randomShuffle(
foreach(i
foreach(j
if (i != j &&
swap(
break;
}
return tuple(
}</lang>
|