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

[장희직] - 게임, 연산자 끼워넣기, 디스크 컨트롤러, A와 B #177

Merged
merged 4 commits into from
Sep 18, 2023

Conversation

jhg3410
Copy link
Member

@jhg3410 jhg3410 commented Sep 18, 2023

📌 from issue #175 📌

📋문제 목록📋

게임: ✅
연산자 끼워넣기: ✅
디스크 컨트롤러: ✅
A와 B: ✅

@jhg3410 jhg3410 self-assigned this Sep 18, 2023
@jhg3410 jhg3410 added the 희직 label Sep 18, 2023
Comment on lines +16 to +17
origin = StringBuilder(readln())
goal = StringBuilder(readln())
Copy link
Contributor

Choose a reason for hiding this comment

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

스트링빌더 아이디어 굿이네요,,,delete해주면 될걸 머리 싸매고 인덱스 계산을 했다니 ㅠㅠ

}

if (plusCount > 0) {
plusCount--
Copy link
Contributor

Choose a reason for hiding this comment

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

오 전 카운트를 전부 인자로 넣어서 함수 호출이 엄청 지저분했었는데 이렇게 하니 깔끔하네요

Copy link
Member

Choose a reason for hiding this comment

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

동의합니다..!!

Copy link
Member

@soopeach soopeach left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

private fun change(): Int {
while (origin.length != goal.length) {
if (goal.last() == 'A') {
goal.deleteAt(goal.lastIndex)
Copy link
Member

Choose a reason for hiding this comment

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

그러게요.. deleteAt 야무지네요

Comment on lines +7 to +15
data class Pos(
val x: Int,
val y: Int
)

data class Area(
var type: Int, // 0 -> 안전, 1 -> 위험, 2-> 죽음
var lostLife: 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 +83 to +101
else if (nextType == 1) {
if (visited[nx][ny].not()) {
visited[nx][ny] = true
queue.add(Pos(nx, ny))
board[nx][ny].lostLife = originLostLife + 1
} else if (originLostLife + 1 < nextLostLife) {
queue.add(Pos(nx, ny))
board[nx][ny].lostLife = originLostLife + 1
}
} else if (nextType == 0) {
if (visited[nx][ny].not()) {
visited[nx][ny] = true
queue.add(Pos(nx, ny))
board[nx][ny].lostLife = originLostLife
} else if (originLostLife < nextLostLife) {
queue.add(Pos(nx, ny))
board[nx][ny].lostLife = originLostLife
}
}
Copy link
Member

Choose a reason for hiding this comment

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

다시 탐색할 가치를 확인하고 다시 queue에 넣어주는 방법은 생각지도 못했는데 대단하십니다

Comment on lines +22 to +26
operators = readln().split(' ').map { it.toInt() }
plusCount = operators[0]
minusCount = operators[1]
multiCount = operators[2]
divideCount = operators[3]
Copy link
Member

Choose a reason for hiding this comment

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

병희님이 말씀하신 구조 분해를 써도 괜찮을 것 같습니다!

}

if (plusCount > 0) {
plusCount--
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 +88 to +91
} else if (originLostLife + 1 < nextLostLife) {
queue.add(Pos(nx, ny))
board[nx][ny].lostLife = originLostLife + 1
}
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 +21 to +28
while (origin.length != goal.length) {
if (goal.last() == 'A') {
goal.deleteAt(goal.lastIndex)
} else {
goal.deleteAt(goal.lastIndex)
goal.reverse()
}
}
Copy link
Member

Choose a reason for hiding this comment

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

오.. 깔끔깔끔

@jhg3410 jhg3410 merged commit d5de136 into main Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants