Skip to content

Commit 3e0b705

Browse files
author
Kahfi Elhady
committed
fix shuffle range bias
1 parent 5c39e87 commit 3e0b705

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sorts/BogoSort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function isSorted(array) {
1616
*/
1717
function shuffle(array) {
1818
for (let i = array.length - 1; i; i--) {
19-
const m = Math.floor(Math.random() * i)
19+
const m = Math.floor(Math.random() * (i + 1))
2020
const n = array[i - 1]
2121
array[i - 1] = array[m]
2222
array[m] = n

0 commit comments

Comments
 (0)