Skip to content
Merged
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
24 changes: 24 additions & 0 deletions Insung-Jo/level_0/개미 군단.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function solution(hp) {
const ARCHER_ANT = 5;
const SOLDIER_ANT = 3;
const WORKER_ANT = 1;
const DEAD = 0;

let prey = hp;
let answer = 0;

while (prey > DEAD) {
if (prey >= ARCHER_ANT) {
prey -= ARCHER_ANT;
answer++;
} else if (prey >= SOLDIER_ANT) {
prey -= SOLDIER_ANT;
answer++;
} else {
prey -= WORKER_ANT;
answer++;
}
}

return answer;
}
7 changes: 7 additions & 0 deletions Insung-Jo/level_0/옷가게 할인 받기.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function solution(price) {
if (price >= 500000) return Math.floor(price - price * 0.2);
if (price >= 300000) return Math.floor(price - price * 0.1);
if (price >= 100000) return Math.floor(price - price * 0.05);

return price;
}