fix: double letter guess scored incorrectly

This commit is contained in:
Jake 2022-02-05 11:34:38 +00:00
parent 147cb22e88
commit a39fce6c07
2 changed files with 7 additions and 0 deletions

View File

@ -49,6 +49,7 @@ func Check(word string, solution string) (correct, present []int) {
// check if correct position // check if correct position
if letter == int32(solution[i]) { if letter == int32(solution[i]) {
correct = append(correct, i) correct = append(correct, i)
exclude = append(exclude, i)
continue continue
} }

View File

@ -54,6 +54,12 @@ func TestCheck(t *testing.T) {
wantCorrect: []int{0, 1, 2, 3, 4}, wantCorrect: []int{0, 1, 2, 3, 4},
wantPresent: []int{}, wantPresent: []int{},
}, },
{
name: "double letter guess",
args: args{word: "trots", solution: "those"},
wantCorrect: []int{0, 2},
wantPresent: []int{4},
},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {