Skip to content

Instantly share code, notes, and snippets.

View amorfati0310's full-sized avatar
:octocat:
make whatever you like

Chany (dali) amorfati0310

:octocat:
make whatever you like
View GitHub Profile
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;
}
}
@amorfati0310
amorfati0310 / digits.js
Created March 12, 2018 07:11
진수변환
// 마우스를 만들어보기
// 1. 원리를 이해하자
// 2. 모양 설계
// 3. 볼 마우스에 필요한 볼 만들기 .........
const getResult = (number, digits) => {
let result = [];
while (number > 0) {
result.unshift(number % digits);
number = parseInt(number / digits);
@amorfati0310
amorfati0310 / scope.js
Last active March 15, 2018 07:26
scope.js
var circle = function(radius) {
return radius * radius * Math.PI;
};
var rect = function(width, height) {
return width * height;
};
// var make = function(fn) {
// return fn;
// };
@amorfati0310
amorfati0310 / codility_binary_01.js
Created March 21, 2018 05:06
codility_binary_01
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;
@amorfati0310
amorfati0310 / codility02.js
Created March 21, 2018 15:59
codility02.js
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)
@amorfati0310
amorfati0310 / codiltity02-02.js
Created March 23, 2018 03:12
codiltity02-02.js
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)
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
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;
})
}
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;
}
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;
}