diff --git "a/Lv.1/2016\353\205\204.kt" "b/Lv.1/2016\353\205\204.kt" new file mode 100644 index 0000000..33341e1 --- /dev/null +++ "b/Lv.1/2016\353\205\204.kt" @@ -0,0 +1,10 @@ +package Lv.`1` + + +fun solution(a: Int, b: Int): String { + val daysOfMonth = listOf(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) + val dayOfWeek = listOf("FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU") + val totalDays = (1 until a).sumOf { daysOfMonth[it] } + b - 1 + + return dayOfWeek[totalDays % 7] +} \ No newline at end of file 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.1/\353\260\224\355\203\225\355\231\224\353\251\264 \354\240\225\353\246\254.kt" "b/Lv.1/\353\260\224\355\203\225\355\231\224\353\251\264 \354\240\225\353\246\254.kt" new file mode 100644 index 0000000..d6a2b53 --- /dev/null +++ "b/Lv.1/\353\260\224\355\203\225\355\231\224\353\251\264 \354\240\225\353\246\254.kt" @@ -0,0 +1,22 @@ +package Lv.`1` + +fun solution(wallpaper: Array): IntArray { + var lux = Int.MAX_VALUE + var luy = Int.MAX_VALUE + var rdx = 0 + var rdy = 0 + + for (i in wallpaper.indices) { + for (j in wallpaper[i].indices) { + if (wallpaper[i][j] == '#') { + lux = minOf(lux, i) + luy = minOf(luy, j) + + rdx = maxOf(rdx, i + 1) + rdy = maxOf(rdy, j + 1) + } + } + } + + return intArrayOf(lux, luy, rdx, rdy) +} \ No newline at end of file diff --git "a/Lv.2/k\354\247\204\354\210\230\354\227\220\354\204\234 \354\206\214\354\210\230 \352\260\234\354\210\230 \352\265\254\355\225\230\352\270\260.kt" "b/Lv.2/k\354\247\204\354\210\230\354\227\220\354\204\234 \354\206\214\354\210\230 \352\260\234\354\210\230 \352\265\254\355\225\230\352\270\260.kt" new file mode 100644 index 0000000..d1264df --- /dev/null +++ "b/Lv.2/k\354\247\204\354\210\230\354\227\220\354\204\234 \354\206\214\354\210\230 \352\260\234\354\210\230 \352\265\254\355\225\230\352\270\260.kt" @@ -0,0 +1,23 @@ +package Lv.`2` + +fun solution(n: Int, k: Int): Int { + val converted = n.toString(k) + val parts = converted.split("0") + var count = 0 + + for (part in parts) { + if (part.isNotEmpty() && checkPrime(part.toLong())) { + count++ + } + } + + return count +} + +fun checkPrime(num: Long): Boolean { + if (num < 2) return false + for (i in 2..Math.sqrt(num.toDouble()).toLong()) { + if (num % i == 0L) return false + } + return true +} \ No newline at end of file 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) + } +} diff --git "a/kotlin_2/\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.kt" "b/kotlin_2/\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.kt" index 42ae60e..70727f8 100644 --- "a/kotlin_2/\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.kt" +++ "b/kotlin_2/\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.kt" @@ -1,7 +1,7 @@ package kotlin_2 class Solution { - fun solution(record: Array): Array { + fun solution(record: Int, intArrayOf: IntArray, intArrayOf1: IntArray): Array { var member: MutableMap = mutableMapOf() record.forEach {