Skip to content

Commit 6aeb2bf

Browse files
authored
Merge pull request #114 from front-studium/Insung-Jo
`week24` 문제 완료
2 parents f46ea32 + bf7ccea commit 6aeb2bf

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function solution(hp) {
2+
const ARCHER_ANT = 5;
3+
const SOLDIER_ANT = 3;
4+
const WORKER_ANT = 1;
5+
const DEAD = 0;
6+
7+
let prey = hp;
8+
let answer = 0;
9+
10+
while (prey > DEAD) {
11+
if (prey >= ARCHER_ANT) {
12+
prey -= ARCHER_ANT;
13+
answer++;
14+
} else if (prey >= SOLDIER_ANT) {
15+
prey -= SOLDIER_ANT;
16+
answer++;
17+
} else {
18+
prey -= WORKER_ANT;
19+
answer++;
20+
}
21+
}
22+
23+
return answer;
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function solution(price) {
2+
if (price >= 500000) return Math.floor(price - price * 0.2);
3+
if (price >= 300000) return Math.floor(price - price * 0.1);
4+
if (price >= 100000) return Math.floor(price - price * 0.05);
5+
6+
return price;
7+
}

0 commit comments

Comments
 (0)