-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[이지민] - 모음사전, 카펫, 반지, 몬스터 트럭, 필터 #3
Conversation
fun order(word: String): Int { | ||
val list = arrayListOf("A", "E", "I", "O", "U", "") | ||
var total = mutableSetOf<String>() | ||
|
||
for (x1 in list) { | ||
for (x2 in list) { | ||
for (x3 in list) { | ||
for (x4 in list) { | ||
for (x5 in list) { | ||
for (x6 in list) { | ||
val newWord = x1 + x2 + x3 + x4 + x5 + x6 | ||
total.add(newWord) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
val sortedTotal = total.filter { it.length < 6 }.sorted() | ||
//println(sortedTotal) | ||
|
||
return sortedTotal.indexOf(word) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드가 엄청 직관적이라서 이해하기가 좋은 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빈 칸까지 쳐서 for문으로 문자열 만들면 모든 경우를 구할 수 있다는 걸 생각 못했는데 이렇게 하면 되는구나 했어요!
val parking = arrayListOf<ArrayList<String>>() | ||
for (i in 0 until x) { | ||
parking.add( | ||
readLine()!!.split("").drop(1).dropLast(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readLine()!! 대신 readln()
을 사용하면 좋을 것 같아요
요기 한번 보셔도 좋을 것 같습니다
fourParking.clear() | ||
continue | ||
} | ||
when (fourParking.count { it.contains("X") }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고차 함수 잘 활용하신 것 같아요!!
val num = readLine()?.toInt() | ||
var rings = arrayListOf<String>() | ||
var sum = 0 | ||
for (i in 0 until num!!) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전 num 변수처럼 다음 입력의 개수를 표시하는 친구는 repeat(readln().toInt()) {} 이렇게 사용해요!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
num의 non-null처리를 19라인에서 ?: 연산자로 하면 !!를 안 쓸 수 있을 것 같아요!
for (i in 1..sqrt(yellow.toDouble()).toInt()) { | ||
if (yellow % i == 0) { | ||
if (brown == (i + 2) * 2 + (yellow / i) * 2) { | ||
return intArrayOf(i + 2, yellow / i + 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍
val pixel = arrayListOf<ArrayList<Int>>() | ||
for (i in 0 until x) { | ||
pixel.add(readLine()!!.trim().split(" ").map { it.toInt() } | ||
as ArrayList<Int>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pixel을 arrayListOf<MutableList<Int>>()
로 사용하시면 22번째에서 입력받은 값(readLine()!! ~~)을 별도로 as ArrayList로 캐스팅하는 대신, toMutableList()로 간단히 형변환을 해줄 수 있어요!!
📌 from issue #1 📌
📋문제 목록📋
📝메모
NubmerFormat 에러
array에 특정 값이 포함되어있는 개수 구하기
IntArray 출력하기