Skip to content

Instantly share code, notes, and snippets.

function solution(N) {
return getRound(N);
}
function getRound(N) {
const tiles = [1, 2];
for(let i = 2; i <= N; i += 1) {
tiles[i] = tiles[i - 2] + tiles[i - 1];
}
function solution(N) {
return getRound(N);
}
function getRound(N) {
const tiles = [1, 2];
for(let i = 2; i <= N; i += 1) {
tiles[i] = tiles[i - 2] + tiles[i - 1];
}
function solution(n, s) {
if(n === 1) return [s];
if(s < n) return [-1];
const ave = parseInt(s/n);
const r = s % n;
const answer = [];
if(r === 0) {
return new Array(n).fill(ave);
function solution(nums) {
const combis = getCombination(nums, 3);
const elementSum = getElmentSum(combis);
const prime = getPrimeNumList(Math.max(...elementSum));
return elementSum.filter(el => prime[el]).length;
}
function getCombination(arr, len = arr.length) {
if (len === 1) return arr.map(el => [el]);
function solution(people, limit) {
let num = people.length;
let start = 0;
let end = num - 1;
let pair = 0;
people.sort((a,b) => a-b);
while(start < end) {
const light = people[start];
function solution(n){
if(n === 1) return 1;
const nArr = Array.from(n.toString(2));
return nArr.reduce((a,b)=>(+a)+(+b));
}
function solution(n,a,b){
let answer = 0;
while(a !== b) {
a = Math.ceil(a / 2);
b = Math.ceil(b / 2);
answer += 1;
}
function solution(str1, str2) {
const multipleSet1 = makeMultipleSet(str1.toUpperCase());
const multipleSet2 = makeMultipleSet(str2.toUpperCase());
const unionAndIntersection = findUnionAndIntersection(multipleSet1, multipleSet2);
return Math.floor((unionAndIntersection[0] / unionAndIntersection[1]) * 65536);
}
function makeMultipleSet(arr) {
function solution(name){
let answer = -1;
let idx = 0;
const newArr = [];
if(/[A]+/.test(name)) {
const match = name.match(/[A]+/g);
let max = 0;
for(let i = 0; i < match.length; i++) {
if(match[i].length > max) {
function solution(skill, skill_trees) {
let skillPos = 0;
let answer = 0;
const findWrongSkillTree = (skillTree, skill) => {
for(let el of skill) {
const currSkillIdx = skillTree.indexOf(el);
if(currSkillIdx === -1) skillPos = currSkillIdx;
if(skillPos === -1 && currSkillIdx >= 0) {