Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions nkim/week8/λ©€μ©‘ν•œμ‚¬κ°ν˜•.js
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 10 additions & 0 deletions nkim/week8/μ˜ˆμ‚°.js
Original file line number Diff line number Diff line change
@@ -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;
}
5 changes: 5 additions & 0 deletions nkim/week8/μŒμ–‘λ”ν•˜κΈ°.js
Original file line number Diff line number Diff line change
@@ -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;
}