Best shuffle: Difference between revisions
Content added Content deleted
(C: incorrect) |
(→{{header|D}}: account for multibyte strings, which the swap would otherwise interfere with) |
||
Line 100:
=={{header|D}}==
{{works with|D|2}}
<lang d>
int countSamePositions(
return count!("a[0] == a[1] && a[1] != b")(zip(r1, r2), '-');
}
const len = s1.length;
if (len < 3) {
Line 131:
} while(countSamePositions(s1, s2) > 0);
for (int i; i < len; i++) {
if (s2[i] == '-') {
s2[i] =
}
}
|