Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
names = ALPHABETH.split('').map(x => repeat('_', n) + x);
}
export function cipherLetterFreq(cipher: string) {
let msg = cipher.toLowerCase();
let freq = repeat(0, 26);
for (let l of msg) {
if (l >= 'a' && l <= 'z') freq[LOWER_CASE.indexOf(l)] += 1;
}
return freq;
}
export function graphColouring(adjMatrix: number[][]) {
let colours = repeat(0, adjMatrix.length);
let result = colourMe(adjMatrix, colours, 0);
return result ? colours : undefined;
}
export function smart(n: number, id: string) {
if (!id) id = uid();
if (!SMART_RANDOM_CACHE.has(id)) SMART_RANDOM_CACHE.set(id, repeat(1, n));
const cache = SMART_RANDOM_CACHE.get(id)!;
const x = weighted(cache.map(x => x * x));
cache[x] -= 1;
if (cache[x] <= 0) SMART_RANDOM_CACHE.set(id, cache.map(x => x + 1));
return x;
}
$step.model.set('probTable', (d: number) => {
let pmax = probabilities[d][Math.round(7 * d / 2)];
let keys = list(d, d * 6);
let row1 = keys.map(i => `<div class="pBox">
<div id="dc2${i}" class="diceCount"></div>
<div style="bottom: ${probabilities[d][i] / pmax * 95}%" class="diceProb">
</div></div>`);
let row2 = keys.map(i => `<span class="dice">${i}</span>`);
let row3 = keys.map(i => probabilities[d][i]);
let row4 = keys.map(i => `<span id="dc1${i}" class="m-blue">0</span>`);
scores = repeat(0, 60);
return table([row1, row2, row3, row4]);
});