-
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
[이지민] 킹, 바닥 장식, 빙고, 랜선 자르기, 가로수 #23
Conversation
treeList.add(readLine().toInt()) | ||
} | ||
|
||
treeList.sort() |
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.
문제에 명확히 조건 표기가 안되어있었지만 정렬해주시는 센스가 좋은 것 같습니다!!👍
treeList.sort() | ||
|
||
val treeDistanceList = arrayListOf<Int>() | ||
treeList.forEachIndexed { index, _ -> |
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.
_처리 깔끔하고 좋은 것 같아요~~
var min = 1L | ||
var max = lanCableList.sorted().last() |
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.
저는 정답을 담을 별도의 변수를 만들었는데 최소 / 최대, 이 두 가지 변수만으로 해결하신게 멋있습니다!
|
||
fun checkRow(n: Int, m: Int): 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.
완탐으로 구현하신 부분이 독특합니다!
|
||
val nowHostResult = mutableListOf<Int>() | ||
|
||
hostResult.flatten().forEachIndexed { idx, it -> |
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.
flatten() 대박인 것 같아요~~ 저는 리스트를 순차탐색해서 원소들을 넣어주었는데..
|
||
fun main(): Unit = with(BufferedReader(InputStreamReader(System.`in`))) { | ||
val (king, dol, n) = readLine().split(" ") | ||
var kingX = king[0] - 'A' |
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.
'A" 자체를 빼서 0으로 만든 부분이 정말 좋은 것 같습니다!!
movementResult.add(readLine()) | ||
} | ||
val movementOfKing = | ||
mapOf<String, Pair<Int, 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.
맵으로 명령어랑 이동할 좌표를 잘 관리하신 것 같아요!!!
근데 맵은 널체크가 계속 필요해서 뭔가 아쉽네요ㅜㅜ
for (i in minDistance downTo 1){ | ||
if (treeDistanceList.all { it % i == 0}) { | ||
treeDistanceList.forEach { | ||
sum += it / i - 1 | ||
} | ||
println(sum) | ||
break |
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.
전 이런 식으로 할 생각을 못 했네요 👍
if (min > max) { | ||
println(max) | ||
break | ||
} |
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.
따로 값을 할당하지 않고 max 값을 결괏값으로 사용할 수 있군요!
for (i in 0 until n) { | ||
for (j in 0 until m) { | ||
if (j == m - 1 && bottomDesign[i][j] == "-") { | ||
num += 1 | ||
} else if (bottomDesign[i][j] == "-" && bottomDesign[i][j + 1] == "|") { | ||
num += 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.
각 내부(j) 값을 계속해서 돌면서 체크하는 부분이 좋은 방법이네요!!
fun checkDiagonal(nowHostResult: MutableList<Int>): Int { | ||
var bingo = 0 | ||
var check1 = true | ||
var check2 = true | ||
for (i in 0 until 5){ | ||
if (userResult[i][i] !in nowHostResult) check1 = false | ||
if (userResult[i][4 - i] !in nowHostResult) check2 = false | ||
} | ||
if (check1) { | ||
bingo += 1 | ||
} | ||
if (check2) { | ||
bingo += 1 | ||
} | ||
|
||
return bingo |
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.
대각선을 합치신 부분이 좋았어요!!
bingo += checkRow(nowHostResult) | ||
bingo += checkColumn(nowHostResult) | ||
bingo += checkDiagonal(nowHostResult) | ||
if (bingo >= 3) { |
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 (i in minDistance downTo 1){ | ||
if (treeDistanceList.all { it % i == 0}) { | ||
treeDistanceList.forEach { | ||
sum += it / i - 1 | ||
} | ||
println(sum) | ||
break | ||
} | ||
} |
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.
어차피 젤 작은 간격보다 최대공약수가 클 수가 없다는 생각 멋집니다..! 시간이 엄청 짧아질 것 같아요
repeat(n) { | ||
bottomDesign.add(readLine().chunked(1).toMutableList()) | ||
} | ||
println(checkRow(n,m) + checkColumn(n,m)) |
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 (i in 0 until m) { | ||
for (j in 0 until n) { |
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.
i j 위치만 바꿔준 게 멋져요,,,👍
|
||
val nowHostResult = mutableListOf<Int>() | ||
|
||
hostResult.flatten().forEachIndexed { idx, it -> |
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.
진짜 flatten() 대박이에요....오늘 딱 기억에 남아서 저도 써먹어봐야겠습니다!!
bingo += checkDiagonal(nowHostResult) | ||
if (bingo >= 3) { | ||
println(idx + 1) | ||
return@with |
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.
with 탈출하는 거 유용해보여요!!!
📌 from issue #21 📌
📋문제 목록📋
📍추가로 해결한 문제📍
📝메모