-
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
[장희직] - 게임, 연산자 끼워넣기, 디스크 컨트롤러, A와 B #177
Conversation
origin = StringBuilder(readln()) | ||
goal = StringBuilder(readln()) |
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.
스트링빌더 아이디어 굿이네요,,,delete해주면 될걸 머리 싸매고 인덱스 계산을 했다니 ㅠㅠ
} | ||
|
||
if (plusCount > 0) { | ||
plusCount-- |
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.
동의합니다..!!
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.
고생하셨습니다!
private fun change(): Int { | ||
while (origin.length != goal.length) { | ||
if (goal.last() == 'A') { | ||
goal.deleteAt(goal.lastIndex) |
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.
그러게요.. deleteAt 야무지네요
data class Pos( | ||
val x: Int, | ||
val y: Int | ||
) | ||
|
||
data class Area( | ||
var type: Int, // 0 -> 안전, 1 -> 위험, 2-> 죽음 | ||
var lostLife: 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.
요거 클래스 안에서 선언하셔도 됩니다!
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 | ||
} | ||
} |
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.
다시 탐색할 가치를 확인하고 다시 queue에 넣어주는 방법은 생각지도 못했는데 대단하십니다
operators = readln().split(' ').map { it.toInt() } | ||
plusCount = operators[0] | ||
minusCount = operators[1] | ||
multiCount = operators[2] | ||
divideCount = operators[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.
병희님이 말씀하신 구조 분해를 써도 괜찮을 것 같습니다!
} | ||
|
||
if (plusCount > 0) { | ||
plusCount-- |
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.
동의합니다..!!
} else if (originLostLife + 1 < nextLostLife) { | ||
queue.add(Pos(nx, ny)) | ||
board[nx][ny].lostLife = originLostLife + 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.
이렇게 갱신해줄 수도 있군요
while (origin.length != goal.length) { | ||
if (goal.last() == 'A') { | ||
goal.deleteAt(goal.lastIndex) | ||
} else { | ||
goal.deleteAt(goal.lastIndex) | ||
goal.reverse() | ||
} | ||
} |
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.
오.. 깔끔깔끔
📌 from issue #175 📌
📋문제 목록📋