-
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Solution 59997d1a390d44568ad4664a7ea13d9e produces this suggestion:
Iterating over a string produces runes. A rune represents a Unicode character and can consist of multiple bytes. Try using runes instead of bytes.
But the solution does use runes:
// Package scrabble provides functions to play the game scrabble.
package scrabble
import "strings"
// Score takes a string and returns its scrabble score as an integer.
func Score(word string) int {
scores := map[string]int{
"aeioulnrst": 1,
"dg": 2,
"bcmp": 3,
"fhvwy": 4,
"k": 5,
"jx": 8,
"qz": 10,
}
var ret int
word = strings.ToLower(word)
for _, j := range word {
for k := range scores {
if strings.ContainsRune(k, j) {
ret += scores[k]
}
}
}
return ret
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels