From a39fce6c079bc76cb4dc08ce4a567b093db5fa64 Mon Sep 17 00:00:00 2001 From: Jake Walker Date: Sat, 5 Feb 2022 11:34:38 +0000 Subject: [PATCH] fix: double letter guess scored incorrectly --- game/words/words.go | 1 + game/words/words_test.go | 6 ++++++ 2 files changed, 7 insertions(+) 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) {