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

[전현수] - 로봇 청소기, 보물섬, 센서, 합분해 #97

Merged
merged 5 commits into from
Feb 19, 2023

Conversation

soopeach
Copy link
Member

📌 from issue #96 📌

📋문제 목록📋

로봇 청소기: ✅
보물섬: ✅
센서: ⛔️
합분해: ✅

📍추가로 해결한 문제📍

추천: 👍  
비추천: 👎  
문제에 대한 간단한 코멘트를 남겨주셔도 좋을 것 같아요!

📝메모

우와... 골드 dp문제 처음 풀어봐요


@soopeach soopeach self-assigned this Feb 19, 2023
NORTH(Position(-1, 0))
}

private inner class Robot {
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 +142 to +162
with(robot) {
while (isNotStop()) {
// 우선 청소
cleanUp()
// 주변에 청소가 안된 곳이 있다면
if (isNotCleanedUpNear()) {
// 반시계 방향으로 회원
rotate()
// 앞쪽이 청소되지 않은 칸일 경우 전진
if (isFrontCleanedUp()) move()
} else {
// 뒤가 벽이라면 종료
if (isBackWall()) {
turnOff()
// 뒤가 벽이 아니라면 후진
} else {
moveBack()
}
}
}
}
Copy link
Member

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

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

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

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

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

Choose a reason for hiding this comment

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

정렬이 빨리 될 거 같아서 pq로 했는데 poll을 k번하는 거 생각하면 리스트를 정렬하고 바로 drop하는 게 더 빠를 수도 있겠네요..!

Comment on lines +110 to +114
fun isNotStop() = isOn

fun turnOff() {
isOn = false
}
Copy link
Member

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

Choose a reason for hiding this comment

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

이게 그냥 합이 되는군요...! 머리 한방 맞고 갑니다

@soopeach soopeach merged commit 3d253bf into main Feb 19, 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