Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit 202d040

Browse files
committed
Update Random Algorithm
1 parent 200a6e8 commit 202d040

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/javascript/utils.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,10 @@ function setCharOnIndex(string, index, char) {
586586
}
587587

588588
function GetRandomIndex(length) {
589-
let MT = new MersenneTwister()
590-
let Rand1 = Math.floor(MT.random() * 10000);
591-
let Rand2 = Rand1 % length;
589+
let MT = new MersenneTwister(Math.floor(Math.random() * 1000000000))
590+
let Rand = Math.floor(MT.random() * length);
592591

593-
return Rand2;
592+
return Rand;
594593
}
595594

596595
function insertStringAtIndex(str, value, index) {

src/javascript/utils_next.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,10 @@ function Uint8ArrayTostring(fileData) {
616616
}
617617

618618
function GetRandomIndex(length) {
619-
let MT = new MersenneTwister()
620-
let Rand1 = Math.floor(MT.random() * 10000);
621-
let Rand2 = Rand1 % length;
619+
let MT = new MersenneTwister(Math.floor(Math.random() * 1000000000))
620+
let Rand = Math.floor(MT.random() * length);
622621

623-
return Rand2;
622+
return Rand;
624623
}
625624

626625
function rotateString(str, n) {

0 commit comments

Comments
 (0)