JSFiddle - React, Tailwind, and code Playground
by evgkch
JavaScript
const ln = Math.log;
const pi = Math.PI;
const lnf = x => (x === 0) || (x === 1) ? 0 : x * (ln(x) - 1) + 0.5 * ln(2 * pi * x);
const solve = h => (a, b, c, d) => {
const A = 4 ** h;
const B = A / 4;
const n = a + b + c + d;
const q = A - n;
const qa = B - a;
const qb = B - b;
const qc = B - c;
const qd = B - d;
const cA = (A - 1) * ln(A);
const cB = 4 * (B - 1) * ln(B);
const S1 = lnf(A) - lnf(n) - lnf(q);
const S2 = 4 * lnf(B) - lnf(a) - lnf(b) - lnf(c) - lnf(d) - lnf(qa) - lnf(qb) - lnf(qc) - lnf(qd);
return [S1, S2, S1 - S2];
};
console.log(solve(5)(32,0,32,32))
const arr = [1,2,3]
arr.shift()
console.log(arr)