Best shuffle: Difference between revisions

→‎{{header|D}}: small optimization
(→‎{{header|D}}: small optimization)
Line 638:
auto s = o.dup;
randomShuffle(s);
foreach (i, ref ci; s) {
if (ci != o[i]) continue;
foreach (j, ref cj; s)
if (ci != cj && ci != o[j] && cj != o[i]) {
Line 644 ⟶ 645:
break;
}
}
 
return tuple(s, count!q{a[0] == a[1]}(zip(s, o)));
}</lang>
Anonymous user