/**
* IMPORTANT: this variable controls the algorithm used to generate collisions.
* Switch the value of this between `mt19937`, `lcg`, and `Math.random` to see
* how each algorithm compares to one another.
*
* 1. MT19937: Mersenne-Twister (with a yuge period size of 2^19937 - 1).
* Implemented here in 450 B of WebAssembly. Designed to be as close to the
* native implementation as possible in terms of performance and uniformity.
* This function seems promising, I'd expect halfway decent results from it.
* I specifically developed this for the @nick/math package's random module,
* to emulate the native Math.random() function as close as possible. See
* the JSR docs at https://jsr.io/@nick/math/doc/~/random for more info.
*
* 2. LCG: Linear Congruential Generator (Park-Miller). The simplest and worst
* performing of all three. Implemented here in 150 B of WebAssembly.
*
* 3. Math.random: Recent versions of v8 use an improved API that is based on
* Mersenne-Twister, so the results should be relatively similar to that
* of the MT19937 function implemented in WebAssembly here. If you're using
* Firefox, Safari, or some other browser, then the results will likely be
* disparate from the MT19937 algorithm, as those browsers use other APIs
* that I'm unfamiliar with at this time.
*/
var random = LCG;
var HAS_UINT32_ARRAY = !(typeof Uint32Array === "undefined")
// its SIGNIFICANTLY slower to use Uint32Array instead of Array.
// probably due to V8's special optimizations for plain Arrays...
var USE_UINT32_ARRAY = false;
var bits_per_word = 32,
address_shift = 5 // log2(bits_per_word)
/**
* Create a new bit set. If a size is provided an array will be allocated
* upfront, which speeds up writes and test operations since bitwise operations
* against undefined require a cast. Providing a size will fix the bitset to
* exactly that size, whereas unsized bitsets grow automatically.
*
* The size of the BitSet is rounded up...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.