// --- function q(x) { return document.querySelector(x); } function qa(x) { return [...document.querySelectorAll(x)]; } function range(x) { return Array.from({length: x}, (v, i) => i); } function rand(x) { return x[Math.floor(Math.random() * x.length)]; } function randpop(x) { return x.splice(Math.floor(Math.random() * x.length), 1)[0]; } // --- function html(x) { var h = document.createElement('div'); h.innerHTML = x; return h.children[0]; } function onenter(ele, f) { ele.addEventListener('keydown', function (e) { if (e.keyCode === 13) { f(e); e.preventDefault(); } }) } // --- class Random { constructor(seed) { this.seed = BigInt(seed); this.next(); } next() { this.seed = (this.seed * 0x5DEECE66Dn + 0xBn) & 0xFFFFFFFFFFFFn; return Number((this.seed >> 10n) & 0xFFFFFFFFn) / 0x100000000; } } // --- Array.prototype.rand = function() { return this[Math.floor(Math.random() * this.length)]; } Array.prototype.randpop = function() { return this.splice(Math.floor(Math.random() * this.length), 1)[0]; } Array.prototype.uniq = function() { return this.filter((i, index, array) => array.indexOf(i) == index); } Array.prototype.shuffle = function() { var n = this.length; while (n) { var i = Math.floor(Math.random() * n--); var t = this[n]; this[n] = this[i]; this[i] = t; } return this; } Object.prototype.values = function() { return Object.values(this); } Object.prototype.keys = function() { return Object.keys(this); } // ---