-
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
Open
cjlee38
wants to merge
25
commits into
woowahan-pjs:main
Choose a base branch
from
cjlee38:cjlee38
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
38e9dde
docs: 기능 요구사항 목록 작성
kth990303 80f767b
feat: 글자 하나를 나타내는 `Letter` 구현
kth990303 da55951
feat: 유효한 단어를 나타내는 `Word` 구현
kth990303 6377d1d
feat: `Word`에서 다른 단어와 비교하는 기능 구현
kth990303 ba0bba1
feat: 예측 단어와 정답 단어 비교 기능 구현
kth990303 17aca8c
refactor: 접근제어자 수정
kth990303 35e26f7
docs: 누락된 요구사항 체크
kth990303 80cdae7
feat: 정답 단어를 날짜에 따라 뽑는 기능 구현
kth990303 d284131
feat: 단어가 소문자로 이루어졌는지 검증하는 로직 추가 구현
kth990303 052464f
feat: 게임을 실행하는 애플리케이션 구현
kth990303 b80b2e3
refactor: EOF 컨벤션 변경
kth990303 ce0abfe
style: `ktlintCheck`에 맞게 컨벤션 변경
kth990303 d2b992b
style: 메소드 순서 변경
cjlee38 0d96a6d
test: DSL 테스트 추가
cjlee38 df8a5b0
fix: 워들 로직 오류 수정
cjlee38 80b7921
refactor: 검증 로직 확장함수로 변경
cjlee38 53f36be
feat: Game 객체 추가 및 게임진행 책임 위임
cjlee38 7feb21f
refactor: 접근제어자 수정
cjlee38 c77d604
style: reformat code
cjlee38 21c766d
refactor: 날짜를 생성자 주입을 통해 받을 수 있도록 변경
cjlee38 4aa60e3
fix: 인덱스 상관없이 일치한 단어를 소진하도록 변경
cjlee38 86c784f
test: 누락한 테스트 수정
cjlee38 04c9896
refactor: 도메인에서 view 값 제거
cjlee38 0a3af01
style: ktlint 적용
cjlee38 d5216d2
style: 한줄 메소드는 식으로 변경
cjlee38 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,18 @@ class Answer(val word: Word) { | |
} | ||
|
||
private fun compareAny(word: Word): List<Int> { | ||
return (RANGE_START..RANGE_END).filter { isAnyMatch(word, it) } | ||
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 | ||
} | ||
return@any false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😲😲😲 |
||
} | ||
} | ||
|
||
private fun merge(greenIndices: List<Int>, yellowIndices: List<Int>): List<Color> { | ||
|
@@ -32,8 +43,4 @@ class Answer(val word: Word) { | |
} | ||
return Color.GRAY | ||
} | ||
|
||
private fun isAnyMatch(word: Word, outerIndex: Int): Boolean { | ||
return (RANGE_START..RANGE_END).any { this.word.compareByIndex(word, it, outerIndex) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,7 @@ | ||||||
package wordle.domain | ||||||
|
||||||
import io.kotest.matchers.collections.shouldContainAll | ||||||
import io.kotest.matchers.collections.shouldContainExactly | ||||||
import org.junit.jupiter.api.DisplayName | ||||||
import org.junit.jupiter.api.Test | ||||||
|
||||||
|
@@ -11,21 +12,16 @@ class AnswerTest { | |||||
fun compareWithGreenAndGray() { | ||||||
val answer = Answer(Word("cigar")) | ||||||
|
||||||
answer.compare(Word("clear")) shouldContainAll listOf( | ||||||
Color.GREEN, | ||||||
Color.GRAY, | ||||||
Color.GRAY, | ||||||
Color.GREEN, | ||||||
Color.GREEN | ||||||
) | ||||||
answer.compare(Word("clear")) shouldContainExactly | ||||||
listOf(Color.GREEN, Color.GRAY, Color.GRAY, Color.GREEN, Color.GREEN) | ||||||
} | ||||||
|
||||||
@Test | ||||||
@DisplayName("완전히 일치하는 글자들만 존재하는 예측을 비교한다. - 정답인 경우") | ||||||
fun compareWithAllGreens() { | ||||||
val answer = Answer(Word("cigar")) | ||||||
|
||||||
answer.compare(Word("cigar")) shouldContainAll | ||||||
answer.compare(Word("cigar")) shouldContainExactly | ||||||
listOf(Color.GREEN, Color.GREEN, Color.GREEN, Color.GREEN, Color.GREEN) | ||||||
} | ||||||
|
||||||
|
@@ -34,7 +30,7 @@ class AnswerTest { | |||||
fun compareWithAllColors() { | ||||||
val answer = Answer(Word("spill")) | ||||||
|
||||||
answer.compare(Word("hello")) shouldContainAll | ||||||
answer.compare(Word("hello")) shouldContainExactly | ||||||
listOf(Color.GRAY, Color.GRAY, Color.YELLOW, Color.GREEN, Color.GRAY) | ||||||
} | ||||||
|
||||||
|
@@ -43,7 +39,7 @@ class AnswerTest { | |||||
fun compareWithYellowAndGray1() { | ||||||
val answer = Answer(Word("front")) | ||||||
|
||||||
answer.compare(Word("totem")) shouldContainAll | ||||||
answer.compare(Word("totem")) shouldContainExactly | ||||||
listOf(Color.YELLOW, Color.YELLOW, Color.GRAY, Color.GRAY, Color.GRAY) | ||||||
} | ||||||
|
||||||
|
@@ -52,16 +48,25 @@ class AnswerTest { | |||||
fun compareWithYellowAndGray2() { | ||||||
val answer = Answer(Word("totem")) | ||||||
|
||||||
answer.compare(Word("start")) shouldContainAll | ||||||
answer.compare(Word("start")) shouldContainExactly | ||||||
listOf(Color.GRAY, Color.YELLOW, Color.GRAY, Color.GRAY, Color.YELLOW) | ||||||
} | ||||||
|
||||||
@Test | ||||||
@DisplayName("위치만 일치하는 글자들과 틀린 글자들이 존재하는 예측을 비교한다..") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
아련해지네요..🌟 |
||||||
fun compareWithYellowAndGray3() { | ||||||
val answer = Answer(Word("witch")) | ||||||
|
||||||
answer.compare(Word("timid")) shouldContainExactly | ||||||
listOf(Color.YELLOW, Color.GREEN, Color.GRAY, Color.GRAY, Color.GRAY) | ||||||
} | ||||||
|
||||||
@Test | ||||||
@DisplayName("전부 틀린 글자들이 존재하는 예측을 비교한다.") | ||||||
fun compareWithAllGrays() { | ||||||
val answer = Answer(Word("parry")) | ||||||
|
||||||
answer.compare(Word("biome")) shouldContainAll | ||||||
answer.compare(Word("biome")) shouldContainExactly | ||||||
listOf(Color.GRAY, Color.GRAY, Color.GRAY, Color.GRAY, Color.GRAY) | ||||||
} | ||||||
|
||||||
|
@@ -70,16 +75,7 @@ class AnswerTest { | |||||
fun compareWithAllYellows() { | ||||||
val answer = Answer(Word("parse")) | ||||||
|
||||||
answer.compare(Word("spear")) shouldContainAll | ||||||
answer.compare(Word("spear")) shouldContainExactly | ||||||
listOf(Color.YELLOW, Color.YELLOW, Color.YELLOW, Color.YELLOW, Color.YELLOW) | ||||||
} | ||||||
|
||||||
@Test | ||||||
@DisplayName("test.") | ||||||
fun test1() { | ||||||
val answer = Answer(Word("witch")) | ||||||
|
||||||
answer.compare(Word("timid")) shouldContainAll | ||||||
listOf(Color.YELLOW, Color.GREEN, Color.GRAY, Color.GRAY, Color.GRAY) | ||||||
} | ||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
해결했다고 생각했는데 여전히 남아있었네요 ㅠ. 해당 부분 다시 수정하였으니 다시 확인해주시면 감사하겠습니다~