diff --git "a/Insung-Jo/level_0/\352\260\234\353\257\270\342\200\205\352\265\260\353\213\250.js" "b/Insung-Jo/level_0/\352\260\234\353\257\270\342\200\205\352\265\260\353\213\250.js" new file mode 100644 index 0000000..5445150 --- /dev/null +++ "b/Insung-Jo/level_0/\352\260\234\353\257\270\342\200\205\352\265\260\353\213\250.js" @@ -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; +} diff --git "a/Insung-Jo/level_0/\354\230\267\352\260\200\352\262\214\342\200\205\355\225\240\354\235\270\342\200\205\353\260\233\352\270\260.js" "b/Insung-Jo/level_0/\354\230\267\352\260\200\352\262\214\342\200\205\355\225\240\354\235\270\342\200\205\353\260\233\352\270\260.js" new file mode 100644 index 0000000..4b9de49 --- /dev/null +++ "b/Insung-Jo/level_0/\354\230\267\352\260\200\352\262\214\342\200\205\355\225\240\354\235\270\342\200\205\353\260\233\352\270\260.js" @@ -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; +}