-
Notifications
You must be signed in to change notification settings - Fork 35
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
[Wordle] 차리(이찬주) 미션 제출합니다. #11
base: main
Are you sure you want to change the base?
Conversation
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.
private val results: MutableList<List<Color>> = mutableListOf() | ||
|
||
fun printIntroduction() { | ||
println("WORDLE을 6번 만에 맞춰 보세요.") |
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.
그렇네요. Game 클래스 내부의 companion object에서 상수로 관리하도록 처리하였습니다~
} | ||
|
||
@Test | ||
@DisplayName("test.") |
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.
DisplayName
으로도 무엇을 테스트하고자 하는지 잘 모르겠어요🥲
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.
이것저것 테스트해보다가 실수로 넣은것같네요.. 이 부분도 수정하였습니다~
private val CACHE: List<String> = File("src/main/resources/words.txt") | ||
.readLines() |
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 printCount(tryCount: Int) { | ||
println("$tryCount/6") |
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.
여기서도 6
이 사용되고 있네요!
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.
반영하였습니다~
val exactIndices = compareExact(word) | ||
val anyIndices = compareAny(word) | ||
return merge(exactIndices, anyIndices) |
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.
단어를 비교하는 로직을 이해하기 쉽네요. 한 수 배우고 갑니다😲😲
} | ||
|
||
private fun playWordle(answer: Answer): Boolean { | ||
repeat(6) { |
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.
6
은 워들 게임에서 의미있는 숫자이지 않을까요?🤔
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.
Game
클래스를 만들어서 내부 Companion object에서 관리하도록 처리하였습니다~
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.
안녕하세요 차리! 리뷰 반영해주신거 확인했습니다👍👍
차리의 꼼꼼한 테스트 코드와 kotest
를 사용한 부분은 저도 인상깊게 봤습니다🤓
추가로 코멘트 남겼는데 확인해주시면 감사하겠습니다!
} | ||
|
||
@Test | ||
@DisplayName("위치만 일치하는 글자들과 틀린 글자들이 존재하는 예측을 비교한다..") |
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.
@DisplayName("위치만 일치하는 글자들과 틀린 글자들이 존재하는 예측을 비교한다..") | |
@DisplayName("위치만 일치하는 글자들과 틀린 글자들이 존재하는 예측을 비교한다.") |
아련해지네요..🌟
private fun String.isLowerCase(): Boolean { | ||
return this.all { it.isLowerCase() } | ||
} | ||
|
||
fun compareByIndex(other: Word, myIndex: Int, otherIndex: Int = myIndex): Boolean { | ||
return word[myIndex] == other.word[otherIndex] | ||
} |
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.
private fun String.isLowerCase(): Boolean { | |
return this.all { it.isLowerCase() } | |
} | |
fun compareByIndex(other: Word, myIndex: Int, otherIndex: Int = myIndex): Boolean { | |
return word[myIndex] == other.word[otherIndex] | |
} | |
private fun String.isLowerCase(): Boolean = this.all { it.isLowerCase() } | |
fun compareByIndex(other: Word, myIndex: Int, otherIndex: Int = myIndex): Boolean = | |
word[myIndex] == other.word[otherIndex] |
간단한 로직은 간결성을 위해 식으로 변경하면 어떨까요?
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.
그렇네요~ 한줄짜리 메소드는 모두 식으로 변경하였습니다~
consumed.add(it) | ||
return true | ||
} | ||
return@any 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.
😲😲😲
GREEN("🟩"), | ||
YELLOW("🟨"), | ||
GRAY("⬜") |
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.
UI영역에서는 초록색, 노란색, 회색으로 결과를 보여주는 부분을 도메인 로직에서 의존하는거 같아요. 당장은 아니더라도 한번 고민해보시면 좋을거 같습니다😊
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.
도메인쪽에서 뷰 로직에 영향을 받는게 좋아보이지는 않네요. view쪽에서 when절로 처리하였습니다~
val consumed = mutableListOf<Int>() | ||
return (RANGE_START..RANGE_END).filter { isAnyMatch(word, it, consumed) } | ||
} | ||
|
||
private fun isAnyMatch(word: Word, outerIndex: Int, consumed: MutableList<Int>): Boolean { | ||
return (RANGE_START..RANGE_END).any { | ||
if (this.word.compareByIndex(word, it, outerIndex) && !consumed.contains(it)) { | ||
consumed.add(it) | ||
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.
워들 로직이 아직 개선되지 않은거 같아요!
만약 정답이 humph
이고 hippy
를 입력한 경우, p
가 한개임을 유추할 수 있도록 첫번째 p
는 회색으로 나와야하지 않을까요?
로마의 리뷰에서 참고해보았는데, 차리도 워들 세부규칙을 참고하면 좋을거 같습니다!
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.
해결했다고 생각했는데 여전히 남아있었네요 ㅠ. 해당 부분 다시 수정하였으니 다시 확인해주시면 감사하겠습니다~
차리 리뷰 반영해주신거 모두 확인했습니다! 빠르게 반영해주셔서 감사합니다🙇♀️ |
wordle 미션 제출합니다
감사합니다 :)