-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (28 loc) · 819 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function rng(seed) {
let t = seed % 2147483647;
if (t <= 0) {
t += 2147483646;
}
return {
next: function () {
return t = 16807 * t % 2147483647;
},
nextFloat: function () {
return (this.next() - 1) / 2147483646;
},
shuffleArray: function (array) {
if (array.length == 0) {
return array;
}
for (let i = array.length - 1; i != 0; i--) {
const r = Math.floor(this.nextFloat() * (i + 1));
[array[i], array[r]] = [array[r], array[i]];
}
return array;
}
}
}
let queue = [];
const seed = 19429417005;
queue.push(...rng(seed).shuffleArray(["Z", "L", "O", "S", "I", "J", "T"]));
console.log(queue, queue.length);