Anonymous user
Best shuffle: Difference between revisions
m
→{{header|D}}
Underscore (talk | contribs) m (→{{header|Haskell}}: Whitespace.) |
m (→{{header|D}}) |
||
Line 9:
<lang d>int bestShuffle(char[] s1) {
int countSamePositions(char[] r1, char[] r2
}
Line 42 ⟶ 36:
swap(s2[i-1], s2[uniform(0, i)]);
}
} while(countSamePositions(s1, s2
char pc = cast(char) problemChar[0];
for (int i; i < len; i++) {
if (s2[i] == '-') {
Line 52 ⟶ 46:
}
int samePos = countSamePositions(s1, s2
writefln("%s %s (%s)", s1, s2, samePos);
|