-
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
[전현수] - 로봇 청소기, 보물섬, 센서, 합분해 #97
Conversation
NORTH(Position(-1, 0)) | ||
} | ||
|
||
private inner class Robot { |
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(robot) { | ||
while (isNotStop()) { | ||
// 우선 청소 | ||
cleanUp() | ||
// 주변에 청소가 안된 곳이 있다면 | ||
if (isNotCleanedUpNear()) { | ||
// 반시계 방향으로 회원 | ||
rotate() | ||
// 앞쪽이 청소되지 않은 칸일 경우 전진 | ||
if (isFrontCleanedUp()) move() | ||
} else { | ||
// 뒤가 벽이라면 종료 | ||
if (isBackWall()) { | ||
turnOff() | ||
// 뒤가 벽이 아니라면 후진 | ||
} else { | ||
moveBack() | ||
} | ||
} | ||
} | ||
} |
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 (nx in 0 until map.size && ny in 0 until map.first().size) { | ||
if (map[nx][ny] == 0) { | ||
map[nx][ny] = cost + 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.
색다른 방식이여서 좋았습니다!!
diffArray.add(diffOfCensor) | ||
} | ||
|
||
println(diffArray.sortedByDescending { it }.drop(targetCnt - 1).sum()) |
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.
대박!!
} | ||
|
||
// 서 남 동 북 | ||
enum class Directions(val position: Position) { |
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(rowCnt) { | ||
val rowData = readln().map { | ||
if (it == 'W') OCEAN else LAND |
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.
int형으로 바꿔서 거리를 맵 자체에 저장하신 게 멋진 설계네요!!
diffArray.add(diffOfCensor) | ||
} | ||
|
||
println(diffArray.sortedByDescending { it }.drop(targetCnt - 1).sum()) |
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.
정렬이 빨리 될 거 같아서 pq로 했는데 poll을 k번하는 거 생각하면 리스트를 정렬하고 바로 drop하는 게 더 빠를 수도 있겠네요..!
fun isNotStop() = isOn | ||
|
||
fun turnOff() { | ||
isOn = false | ||
} |
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.
이런 것까지 함수로 만든 그는.. 엄청나다...
diffArray.add(diffOfCensor) | ||
} | ||
|
||
println(diffArray.sortedByDescending { it }.drop(targetCnt - 1).sum()) |
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 #96 📌
📋문제 목록📋
📍추가로 해결한 문제📍
📝메모
우와... 골드 dp문제 처음 풀어봐요