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
20 changes: 20 additions & 0 deletions 은서/week5/기사단원의 무기.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function solution(number, limit, power) {
var answer = 0;
for (let i = 1; i <= number; i++) {
let count = 0;
for (let j = 1; j <= i / 2; j++) {
if (i % j === 0) {
count += 1;
}
}

count += 1;

if (count > limit) {
answer += power;
} else {
answer += count;
}
}
return answer;
}
17 changes: 17 additions & 0 deletions 은서/week5/명예의 전당(1).js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function solution(k, score) {
const honor = [];
const ans = [];

score.forEach((n) => {
honor.push(n);
honor.sort((a, b) => b - a);

if (honor.length >= k) {
ans.push(honor[k - 1]);
} else {
ans.push(honor[honor.length - 1]);
}
});

return ans;
}
14 changes: 14 additions & 0 deletions 은서/week5/콜라 문제.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const solution = (a, b, n) => {
let ans = 0;
let remain = n;

while (true) {
if (a > remain) {
break;
}
ans += parseInt(remain / a) * b;
remain = parseInt(remain / a) * b + (remain % a);
}

return ans;
};