Started to implement server

This commit is contained in:
didier amyot committed 2023-06-11 15:43:45 -04:00
1 parent 1f2ea8b7e5
commit 17a1b4bed3
177 files changed
+29894 -74

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
export function* randomNumbers(seed: number, max: number) : Generator<number> {
const a = 48271;
const m = 2147483647;
max = Math.floor(max);
while (true) {
seed = (a * seed) % m;
yield seed % max;
}
}
export function range(min: number, max: number): number[]{
const ret = []
for(let i = min; i < max; i ++){
ret.push(i);
}
return ret;
}
export function generateLargeText(seed: number, size: number): string {
const words = [
"Norway",
"Germany",
"Ecuador",
"Chile",
"Colombia",
"Sri Lanka",
"Guinea",
"United Kingdom",
"Egypt",
"Palau",
"Latvia",
"Congo, Democratic Republic of the",
"Malawi",
"Senegal",
"Trinidad and Tobago",
"Guatemala",
"Chad",
"New Zealand",
"Malaysia",
"Lithuania",
"Taiwan",
"Solomon Islands",
"Grenada",
"Hungary",
"Korea, South",
];
let ret: string[] = [];
for (let i = 0; i < size; i++) {
seed = (seed * 4931 + 2753) % words.length;
ret.push(words[seed]);
}
return ret.join(" ");
}