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

[장희직] 기적의 매매법, 수 이어 쓰기 1, 등수 구하기, DNA #64

Merged
merged 7 commits into from
Jan 1, 2023

Conversation

jhg3410
Copy link
Member

@jhg3410 jhg3410 commented Jan 1, 2023

📌 from issue #61 📌

📋문제 목록📋

기적의 매매법: ✅
수 이어 쓰기 1: ✅
등수 구하기: ✅
DNA: ✅

📍추가로 해결한 문제📍

@jhg3410 jhg3410 added the 희직 label Jan 1, 2023
@jhg3410 jhg3410 self-assigned this Jan 1, 2023
dnaList.forEach { dna -> dnaByIdx += dna[it] }

var maxCnt = 0
"ACGT".forEach { c -> maxCnt = max(maxCnt, dnaByIdx.count { c == it }) }
Copy link
Contributor

Choose a reason for hiding this comment

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

문자열 써서 인덱스로 이용하는 거 좋아보이네요...👍

}
val scores = readln().split(' ').map { it.toInt() }.toMutableList()

scores.sort()
Copy link
Contributor

Choose a reason for hiding this comment

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

거꾸로 정렬하신 것도 신기했는데 count로 세면 아예 정렬할 필요가 없는 게 대박이네유..

"ACGT".forEach { c -> maxCnt = max(maxCnt, dnaByIdx.count { c == it }) }

answerDna += dnaByIdx.filter { c -> maxCnt == dnaByIdx.count { c == it } }.min()
answerCnt += dnaByIdx.count { it != answerDna.last() }
Copy link
Contributor

Choose a reason for hiding this comment

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

여기가 혹시 n - maxCnt도 되지 않을까요!

var maxCnt = 0
"ACGT".forEach { c -> maxCnt = max(maxCnt, dnaByIdx.count { c == it }) }

answerDna += dnaByIdx.filter { c -> maxCnt == dnaByIdx.count { c == it } }.min()
Copy link
Member

Choose a reason for hiding this comment

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

문자열이랑 고차함수를 엄청 잘 다루시네요!

if (scores.count { it >= score } >= p) {
println(-1)
} else {
println(scores.count { it > score } + 1)
Copy link
Member

Choose a reason for hiding this comment

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

count를 단순히 개수를 셀 때만 이용했는데... 역시 똑똑하십니다.

Comment on lines +16 to +24
private fun getDigit(_num : Int): Int {
var num = _num
var cnt = 0
while (num != 0) {
num /= 10
cnt ++
}
return cnt
}
Copy link
Member

Choose a reason for hiding this comment

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

엄청 깔끔하게 푸셔서 놀랐어요!

@@ -0,0 +1,71 @@
package heejik.`13week`

class `🐜 기적의 매매법 🐜` {
Copy link
Member

Choose a reason for hiding this comment

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

개미까지 복사하신게 인상깊네요 :)

dnaList.forEach { dna -> dnaByIdx += dna[it] }

var maxCnt = 0
"ACGT".forEach { c -> maxCnt = max(maxCnt, dnaByIdx.count { c == it }) }
Copy link
Member

Choose a reason for hiding this comment

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

ACGT 문자열로 만들어 푸신게 인상적이었습니다!


scores.sort()

if (scores.count { it >= score } >= p) {
Copy link
Member

Choose a reason for hiding this comment

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

count 활용을 잘하시네요 👍

Comment on lines +9 to +10
val bnf = bnf(money, stocks)
val timing = timing(money, stocks)
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 7df0ea5 into main Jan 1, 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