Skip to content

Instantly share code, notes, and snippets.

View e-mihaylin's full-sized avatar
🏠
Working from home

Eugene Mihaylin e-mihaylin

🏠
Working from home
View GitHub Profile
//https://www.codewars.com/kata/596d34df24a04ee1e3000a25
const countOnes = (a, b) => cab(b) - cab(a - 1);
const cab = n => {
let bits = 0;
for (let i = 0; i < 30; ++i)
bits += ccb(i, n);
return bits;
}
class Calculator {
evaluate (s) {
s = s.replace(/\s/g, '');
const l = s.length;
const stack = [];
let i = 0;
let o = '+';
while (i < l) {
const x = s[i];
if (/\d/.test(x)) {
const lcm = (...a) => {
const gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
const lcm = (a, b) => a * b / gcd(a, b);
return a.reduce(lcm);
}