Skip to content
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

Merged
merged 5 commits into from
Oct 16, 2022

Conversation

jeeminimini
Copy link
Member

📌 from issue #21 📌

📋문제 목록📋

킹: ✅
바닥 장식: ✅
빙고: ✅
랜선 자르기: ✅
가로수: ✅

📍추가로 해결한 문제📍

📝메모

treeList.add(readLine().toInt())
}

treeList.sort()
Copy link
Member

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, _ ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_처리 깔끔하고 좋은 것 같아요~~

Comment on lines +24 to +25
var min = 1L
var max = lanCableList.sorted().last()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 정답을 담을 별도의 변수를 만들었는데 최소 / 최대, 이 두 가지 변수만으로 해결하신게 멋있습니다!

Comment on lines +24 to +25

fun checkRow(n: Int, m: Int): Int {
Copy link
Member

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 ->
Copy link
Member

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'
Copy link
Member

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>>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맵으로 명령어랑 이동할 좌표를 잘 관리하신 것 같아요!!!
근데 맵은 널체크가 계속 필요해서 뭔가 아쉽네요ㅜㅜ

Comment on lines +35 to +41
for (i in minDistance downTo 1){
if (treeDistanceList.all { it % i == 0}) {
treeDistanceList.forEach {
sum += it / i - 1
}
println(sum)
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전 이런 식으로 할 생각을 못 했네요 👍

Comment on lines +27 to +30
if (min > max) {
println(max)
break
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

따로 값을 할당하지 않고 max 값을 결괏값으로 사용할 수 있군요!

Comment on lines +27 to +32
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

각 내부(j) 값을 계속해서 돌면서 체크하는 부분이 좋은 방법이네요!!

Comment on lines +68 to +83
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

대각선을 합치신 부분이 좋았어요!!

Comment on lines +32 to +35
bingo += checkRow(nowHostResult)
bingo += checkColumn(nowHostResult)
bingo += checkDiagonal(nowHostResult)
if (bingo >= 3) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔끔해요!!👍

Comment on lines +35 to +43
for (i in minDistance downTo 1){
if (treeDistanceList.all { it % i == 0}) {
treeDistanceList.forEach {
sum += it / i - 1
}
println(sum)
break
}
}
Copy link
Contributor

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가로 세로 따로 세서 더하는 게 깔끔해보여서 멋졌습니다!

Comment on lines +41 to +42
for (i in 0 until m) {
for (j in 0 until n) {
Copy link
Contributor

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 ->
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with 탈출하는 거 유용해보여요!!!

@jeeminimini jeeminimini merged commit 67fa0d8 into main Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants