word.go 279 B

12345678910111213141516171819
  1. package main
  2. type Word struct {
  3. Word string
  4. Score int
  5. }
  6. func (w Word) MatchesGuess(guess string, numMatchingChars int) bool {
  7. score := 0
  8. for idx, letter := range w.Word {
  9. if string(letter) == string(guess[idx]) {
  10. score++
  11. }
  12. }
  13. return score == numMatchingChars
  14. }