1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| val (str, n) = readLine()!!.split(' ').let { it[0] to it[1].toInt() }
print(readLine()!!.split(' ').joinToString(""))
fun String.replaceRange(startIndex: Int, endIndex: Int, replacement: String): String
intArrayOf(1,2,3,4).fold(0) { sum, element -> sum + element }
intArrayOf(1,2,3,4).reduce { sum, element -> sum + element }
val numbers = listOf(1, 2, 3, 4, 5) val (even, odd) = numbers.partition { it % 2 == 0 }
numbers.partition{}.let { (first, second) -> ... }
val map = mapOf<Int>('a' to 3, 'b' to 4, 'c' to 5) map.keys.first() map.keys.last()
val diceResults = listOf(3, 4, 3, 5) val groupedResults = diceResults.groupingBy { it }.eachCount() println(groupedResults)
myStrings.indices.joinToString("") {
myArr.indices.map { } ((idx..myArr).lastIndex).map { }
(i..j).firstOrNull { condition } ?: -1 (i..j).takeWhile { condition }
generateSequence(초기값/식, {생성 조건식}) .takeWhile { 조건식 } .map { } .blahBlah { }
arr.indexOfFirst { it>0 }
val listOfLists = listOf(listOf(1, 2), listOf(3, 4), listOf(5, 6)) val flatMapResult = listOfLists.flatMap { it.map { it * 2 } }
val result = listOfLists.map { it.map { it * 2 } }.flatten()
val result = str_list.toList().chunked(n) { it[0] }
myString.trim().split("\s+".toRegex())
val emailRegex = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$".toRegex() val email = "example@test.com" val isValidEmail = email.matches(emailRegex)
str1.zip(str2).joinToString("") { (a, b) -> "$a$b" }
import java.util.* stack.push(arr[i]) else stack.pop()
import java.util.PriorityQueue val pq = PriorityQueue<T>(compareBy {}) pq.peek() pq.poll()
ceil(number).toInt() floor(number).toInt() round(number).toInt()
|