diff options
| author | Maksymilian Jopek <maks@jopek.eu> | 2022-06-02 23:13:07 +0200 |
|---|---|---|
| committer | Maksymilian Jopek <maks@jopek.eu> | 2022-06-02 23:16:33 +0200 |
| commit | b4defa324a330217f0139f1240bcf53c0b1f996a (patch) | |
| tree | deabb94fd351b10d3d6b38d967424149536b3927 /src/helpers.ts | |
| parent | ef76266d1a61c02f1721efedc830fab12279d2b9 (diff) | |
| download | 1942-b4defa324a330217f0139f1240bcf53c0b1f996a.tar.gz 1942-b4defa324a330217f0139f1240bcf53c0b1f996a.tar.zst 1942-b4defa324a330217f0139f1240bcf53c0b1f996a.zip | |
v1.0.0
Diffstat (limited to 'src/helpers.ts')
| -rw-r--r-- | src/helpers.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/helpers.ts b/src/helpers.ts index 9bb1eac..a867b1e 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -11,3 +11,8 @@ export function random(p: number): boolean { if (p < 0 || p > 1) throw Error("Wrong probability - " + p) return Math.random() < p; } +export function randomInteger(min: number, max: number) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; +} |
