diff --git "a/nkim/week8/\353\251\200\354\251\241\355\225\234\354\202\254\352\260\201\355\230\225.js" "b/nkim/week8/\353\251\200\354\251\241\355\225\234\354\202\254\352\260\201\355\230\225.js" new file mode 100644 index 0000000..01e6863 --- /dev/null +++ "b/nkim/week8/\353\251\200\354\251\241\355\225\234\354\202\254\352\260\201\355\230\225.js" @@ -0,0 +1,14 @@ +function solution(w, h) { + var answer = w * h; + let non = 0; + const m = h / w; + + for (let y = 0; y < h; y++) { + const x1 = Math.floor(y / m); + const x2 = Math.floor((y + 1) / m); + non += m % ((y + 1) / x2) ? x2 - x1 + 1 : x2 - x1; + } + answer = answer - non; + // feat 거니 지원 예나의 도움 ㅎㅎ + return answer; +} diff --git "a/nkim/week8/\354\230\210\354\202\260.js" "b/nkim/week8/\354\230\210\354\202\260.js" new file mode 100644 index 0000000..8c3f6d9 --- /dev/null +++ "b/nkim/week8/\354\230\210\354\202\260.js" @@ -0,0 +1,10 @@ +function solution(d, budget) { + var answer = 0; + d.sort((a, b) => a - b); + d.reduce((acc, cur, i, origin) => { + if (acc + cur > budget) origin.splice(1); + else answer++; + return acc + cur; + }, 0); + return answer; +} diff --git "a/nkim/week8/\354\235\214\354\226\221\353\215\224\355\225\230\352\270\260.js" "b/nkim/week8/\354\235\214\354\226\221\353\215\224\355\225\230\352\270\260.js" new file mode 100644 index 0000000..a395ced --- /dev/null +++ "b/nkim/week8/\354\235\214\354\226\221\353\215\224\355\225\230\352\270\260.js" @@ -0,0 +1,5 @@ +function solution(absolutes, signs) { + var answer = 123456789; + answer = absolutes.reduce((acc, cur, i) => acc + (signs[i] ? cur : -cur), 0); + return answer; +}