Kotlin

Kotlin collections extension function
컬렉션들에 확장함수들을 잘 활용하면 원하는 값을 빠르게 얻을 수 있다. [참고블로그] Filter [공식문서] # 1~10 까지의 수에서 합이 10이 되는 조합이 몇 종류인지 구해본다. (1..10).filter{ 10 - it

emptyList()
비어있는 리스트 표현 [보러가기] Returns an empty read-only list. The returned list is serializable (JVM). val list = listOf() println("list.isEmpty() is ${list.isEmpty()}") // true // another way to create an empty list, // type parameter is inferred from the expected type val other: List = emptyList() // Empty lists are equal println("list == other is ${list == other}") // true println(list) // [] println(o..

Kotlin 조건문
가정문 fun main(args: Array) { val num = -7 if (num > 0) { println("Positive") } else if (num 0) "Positive" else "Negative" println(result) } 코틀린은 변수명에 가정문을 반영 할 수 있다. When 가정문 fun main(args: Array) { val num = -7 val result = when { num > 0 -> "Positive" num ..
![[프로그래머스 뿌셔뿌셔] :Kotlin: 크레인 인형 뽑기 게임](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fr5soY%2FbtqSsQSqQiQ%2FzigF4WKhl4famj1f0k8hZ0%2Fimg.png)
[프로그래머스 뿌셔뿌셔] :Kotlin: 크레인 인형 뽑기 게임
🧱 프로그래머스 코틀린 공부 🛸 크레인 인형 뽑기 게임 문제 : ( 보러가기 ) 해설 : 이 문제는 크레인이 다차원 배열로 된 배열의 숫자를 뽑아서 같은 수일 경우 없애준다. 이 없애준 수의 갯수를 리턴하라는 문제이다. 위의 사진 처럼 인형이 배열되어있다. 이것을 간단히 예로 표현하면 아래와 같다. 0 0 0 0 0 0 0 1 0 5 0 3 2 0 1 4 3 4 4 3 5 2 1 5 1 이렇게 5*5 형태로 2차원 배열을 준다. 나는 이 부분에서 혼동이 와서 헤맸다.. 주어진 테스트 케이스는 아래와 같이 준다. [[00000],[00105],[03201],[43443],[52151]] 이부분을 반대로 생각해서 많이 해맸지만 이 부분을 어렵게 보지말고 위의 표처럼 쭈욱 쌓여있다는 상태로 본다면 이해가 빠르..