Commit 21221c4
committed
fix: unbiased Fisher-Yates in bogoSort; stop mutating RGB input
- shuffle() used Math.random() * i and swapped with i-1, which is a
biased shuffle that cannot produce all permutations. Use standard
Fisher-Yates over [0, i].
- rgbToHsl aliased the input array and overwrote it with HSL values.
Copy the input first so callers keep their RGB data.
Fixes #1867
Fixes #19071 parent 5c39e87 commit 21221c4
2 files changed
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
0 commit comments