diff --git "a/Lv.1/\352\270\260\354\202\254\353\213\250\354\233\220\354\235\230 \353\254\264\352\270\260.kt" "b/Lv.1/\352\270\260\354\202\254\353\213\250\354\233\220\354\235\230 \353\254\264\352\270\260.kt" new file mode 100644 index 0000000..661db53 --- /dev/null +++ "b/Lv.1/\352\270\260\354\202\254\353\213\250\354\233\220\354\235\230 \353\254\264\352\270\260.kt" @@ -0,0 +1,28 @@ +package Lv.`1` + +class Solution4 { + fun solution(number: Int, limit: Int, power: Int): Int { + var answer: Int = 0 + + for (i in 1..number) { + var divisorCount = 0 + + for (j in 1..Math.sqrt(i.toDouble()).toInt()) { + if (i % j == 0) { + divisorCount += 1 + if (j != i / j) { + divisorCount += 1 + } + } + } + + if (divisorCount > limit) { + answer += power + } else { + answer += divisorCount + } + } + + return answer + } +} diff --git "a/Lv.1/\353\217\231\354\230\201\354\203\201 \354\236\254\354\203\235\352\270\260.kt" "b/Lv.1/\353\217\231\354\230\201\354\203\201 \354\236\254\354\203\235\352\270\260.kt" new file mode 100644 index 0000000..6b82fdd --- /dev/null +++ "b/Lv.1/\353\217\231\354\230\201\354\203\201 \354\236\254\354\203\235\352\270\260.kt" @@ -0,0 +1,42 @@ +package Lv.`1` + +class Solution5 { + fun solution(videoLen: String, pos: String, opStart: String, opEnd: String, commands: Array): String { + fun timeToSeconds(time: String): Int { + val parts = time.split(":") + return parts[0].toInt() * 60 + parts[1].toInt() + } + + fun secondsToTime(seconds: Int): String { + val minutes = seconds / 60 + val secs = seconds % 60 + return String.format("%02d:%02d", minutes, secs) + } + + val videoLength = timeToSeconds(videoLen) + val openingStart = timeToSeconds(opStart) + val openingEnd = timeToSeconds(opEnd) + var currentPosition = timeToSeconds(pos) + + if (currentPosition in openingStart..openingEnd) { + currentPosition = openingEnd + } + + for (command in commands) { + when (command) { + "prev" -> { + currentPosition = (currentPosition - 10).coerceAtLeast(0) + } + "next" -> { + currentPosition = (currentPosition + 10).coerceAtMost(videoLength) + } + } + + if (currentPosition in openingStart..openingEnd) { + currentPosition = openingEnd + } + } + + return secondsToTime(currentPosition) + } +} diff --git "a/Lv.2/\354\235\264\354\247\204 \353\263\200\355\231\230 \353\260\230\353\263\265\355\225\230\352\270\260.kt" "b/Lv.2/\354\235\264\354\247\204 \353\263\200\355\231\230 \353\260\230\353\263\265\355\225\230\352\270\260.kt" new file mode 100644 index 0000000..fab2659 --- /dev/null +++ "b/Lv.2/\354\235\264\354\247\204 \353\263\200\355\231\230 \353\260\230\353\263\265\355\225\230\352\270\260.kt" @@ -0,0 +1,22 @@ +package Lv.`2` + +class Solution { + fun solution(s: String): IntArray { + var count = 0 + var zeroCount = 0 + var currentString = s + + while (currentString != "1") { + val zeros = currentString.count { it == '0' } + zeroCount += zeros + + val length = currentString.length - zeros + + currentString = Integer.toBinaryString(length) + + count++ + } + + return intArrayOf(count, zeroCount) + } +}