diff --git a/game/words/words.go b/game/words/words.go index 176389b..3ed96ac 100644 --- a/game/words/words.go +++ b/game/words/words.go @@ -49,6 +49,7 @@ func Check(word string, solution string) (correct, present []int) { // check if correct position if letter == int32(solution[i]) { correct = append(correct, i) + exclude = append(exclude, i) continue } diff --git a/game/words/words_test.go b/game/words/words_test.go index 85ae06b..5cbca1a 100644 --- a/game/words/words_test.go +++ b/game/words/words_test.go @@ -54,6 +54,12 @@ func TestCheck(t *testing.T) { wantCorrect: []int{0, 1, 2, 3, 4}, wantPresent: []int{}, }, + { + name: "double letter guess", + args: args{word: "trots", solution: "those"}, + wantCorrect: []int{0, 2}, + wantPresent: []int{4}, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {