This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getMaxDivisor = (...args) => { | |
let minNumber = Math.min(...args); | |
let NumbersLength = args.length; | |
for(divisor = minNumber; divisor >= 1; divisor--) { | |
for(i=0; i < NumbersLength; i++) { | |
if(args[i]%divisor !== 0) break; | |
} | |
if(i === NumbersLength) return divisor; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 마우스를 만들어보기 | |
// 1. 원리를 이해하자 | |
// 2. 모양 설계 | |
// 3. 볼 마우스에 필요한 볼 만들기 ......... | |
const getResult = (number, digits) => { | |
let result = []; | |
while (number > 0) { | |
result.unshift(number % digits); | |
number = parseInt(number / digits); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var circle = function(radius) { | |
return radius * radius * Math.PI; | |
}; | |
var rect = function(width, height) { | |
return width * height; | |
}; | |
// var make = function(fn) { | |
// return fn; | |
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(number) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
let before, | |
rest, | |
zeroGapStart = false, | |
zeroCount = 0, | |
maxZeros = 0; | |
const Two = 2; | |
while(number > 0){ | |
rest = number%Two; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(A,K) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
const length = A.length; | |
// 1 4 | |
// 2 3 | |
// 3 2 | |
// 4 1 | |
// 5 0 | |
// 6 4 | |
const startIdx = length - (K % length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(arr) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
const reducer = (a, c, ci, ar) => { | |
console.log('asdasda', a, c, ci, ar); | |
if (a.length === 0) { | |
const filtered = ar.filter(el => el !== c) | |
return filtered; | |
} | |
if (a.length === 1) return a; | |
return a.filter(el => el !== c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
// A -> P | |
let P = []; | |
let plusRest = 0; | |
let minusRest = A.reduce((a, b) => a + b); | |
let diff; | |
A.forEach(val => { | |
plusRest += val | |
minusRest -= val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
const numbers = [...Array(A.length + 1).keys()].map(x => x + 1) | |
return numbers.concat(A).reduce((prev, cur) => { | |
return prev ^= cur; | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://app.codility.com/demo/results/trainingQSUQJ3-KVW/ | |
function solution(A) { | |
const numbers = [...Array(A.length).keys()].map(x => x + 1) | |
A.sort((a, b) => a - b); | |
if (A.join('') == numbers.join('')) return 1 | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
const dicA = A.reduce((ac, c) => { | |
ac[c] = c | |
return ac; | |
}, {}) | |
for (let i = 1; i <= A.length + 1; i++) { | |
if (dicA[i] !== i) return i; | |
} |
OlderNewer