We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 67bdac4 commit 0dd55b3Copy full SHA for 0dd55b3
src/kernel/_fisheryates.js
@@ -4,7 +4,9 @@
4
5
const _fisheryates = (randint) => (n, a, i, j) => {
6
// We will swap at most n elements
7
-
+ // NOTE: When n = j - i, the last swap swaps a[j-1] with itself,
8
+ // which is a NOOP. /!\ HOWEVER, the last swap is NOT a NOOP when
9
+ // n < j - i. Hence we cannot let k = i + n - 1 in general.
10
const k = i + n;
11
12
for (; i < k; ++i) {
0 commit comments