-
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
Week5 #13
base: main
Are you sure you want to change the base?
Conversation
arinming
commented
Oct 5, 2024
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.
이번주도 고생하셨어요~~~
fun solution(a: Int, b: Int): String { | ||
val daysOfMonth = listOf(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) | ||
val dayOfWeek = listOf("FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU") | ||
val totalDays = (1 until a).sumOf { daysOfMonth[it] } + b - 1 | ||
|
||
return dayOfWeek[totalDays % 7] | ||
} |
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.
사실 제 코드 처음에 너무 복잡하길래 블로그에서 이거저것........눈팅했읍니다
fun checkPrime(num: Long): Boolean { | ||
if (num < 2) return false | ||
for (i in 2..Math.sqrt(num.toDouble()).toLong()) { | ||
if (num % i == 0L) return false | ||
} | ||
return true | ||
} |
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.
저도 이번에 구현하면서 깨달은건데 짝수는 2로 나눠지니 2로 나눠보고, 그 후부터는 3으로 시작해서 2씩 늘리면 시간이 완전 단축되더라구요!
물론 에라토스테네스의 체 같은 알고리즘을 쓰면 좋지만 그걸 전 외우진 못해서... ㅎㅎ...
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.
오오오오옹..........!!!!!!!!!!!!!! 그런 부분까지,,. 진짜 코테는 너머 어려워요 ㅠㅠ