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

[전현수] - 케빈 베이컨의 6단계 법칙, 함께 블록 쌓기, 전구와 스위치, CCW #171

Merged
merged 4 commits into from
Sep 11, 2023

Conversation

soopeach
Copy link
Member

📌 from issue #170 📌

📋문제 목록📋

케빈 베이컨의 6단계 법칙: ✅
함께 블록 쌓기: ⛔️
전구와 스위치: ⛔️
CCW: ⛔️

📍추가로 해결한 문제📍

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

📝메모

공유하고 싶은 정보, 새롭게 알게된 것, 문제를 풀면서 발생한 에로사항 등...자유롭게!


@soopeach soopeach self-assigned this Sep 11, 2023
Comment on lines +30 to +44
val first = (0..2).run {
var triangle = 0
this.forEach { index ->
triangle += p[index % 3].x * p[(index + 1) % 3].y
}
triangle
}

val second = (1..3).run {
var triangle = 0
this.forEach { index ->
triangle += p[index % 3].y * p[(index + 1) % 3].x
}
triangle
}
Copy link
Contributor

Choose a reason for hiding this comment

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

직접 공식을 로직으로 짜신게 대단합니다👍

}

when {
firstCase.contentEquals(targetState) -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any의 equals 때문에 머리가 아프네요.....아무리 공부해도 어렵다 코틀린..

Comment on lines +72 to +85
private fun Array<String>.switch(pos: Int) {
when (pos) {
bulbCnt - 1 -> {
this.singleSwitch(pos - 1)
this.singleSwitch(pos)
}

else -> {
this.singleSwitch(pos - 1)
this.singleSwitch(pos)
this.singleSwitch(pos + 1)
}
}
}
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 +37 to +49
for (i in 1..studentCnt) {
for (j in 1..targetHeight) {
dp[i][j] += dp[i - 1][j]
dp[i][j] %= 10007

studentInfo[i].forEach { blockHeight ->
val target = j - blockHeight
if (target < 0) return@forEach
dp[i][j] += dp[i - 1][target]
dp[i][j] %= 10007
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

이중 for문 깔꼼하네요!! dp가 원래 이렇게 깔끔한 문젠데 왜 매번 지저분하게 풀어질까요..ㅋㅋㅋㅋㅋ

Comment on lines +72 to +85
private fun Array<String>.switch(pos: Int) {
when (pos) {
bulbCnt - 1 -> {
this.singleSwitch(pos - 1)
this.singleSwitch(pos)
}

else -> {
this.singleSwitch(pos - 1)
this.singleSwitch(pos)
this.singleSwitch(pos + 1)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

switch 함수 만드니까 깔끔하니 좋네요!

}
}

println(dp[studentCnt][targetHeight] % 10007)
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 Author

Choose a reason for hiding this comment

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

없는 것 같아요...

Comment on lines +23 to +28
readln().split(" ")
.map { it.toInt() }
.run {
Point(first(), 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 +72 to +85
private fun Array<String>.switch(pos: Int) {
when (pos) {
bulbCnt - 1 -> {
this.singleSwitch(pos - 1)
this.singleSwitch(pos)
}

else -> {
this.singleSwitch(pos - 1)
this.singleSwitch(pos)
this.singleSwitch(pos + 1)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

👍👍👍

dp[i][j] += dp[i - 1][j]
dp[i][j] %= 10007

studentInfo[i].forEach { blockHeight ->
Copy link
Member

Choose a reason for hiding this comment

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

studentInfo 에 미리 입력을 저장하고 하니 보기 좋네요!!

@soopeach soopeach merged commit 1ce54c1 into main Sep 11, 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