Closed dysolution closed 5 years ago
Thanks! I will have a look at it.
Same issue with 56b5e2a3532e4388bc861460bd6af8ef:
// Package scrabble computes scrabble score
// This is the prettier (much slower) version (iteration 2)
package scrabble
import (
"regexp"
"strings"
)
// letterPoints specifies regexes to chars and how many points they're worth
var letterPoints = map[string]int{
"A|E|I|O|U|L|N|R|S|T": 1,
"D|G": 2,
"B|C|M|P": 3,
"F|H|V|W|Y": 4,
"K": 5,
"J|X": 8,
"Q|Z": 10,
}
// Score function to calculate the score of a given word
func Score(word string) int {
var totalPoints int
word = strings.ToUpper(word)
for letters, points := range letterPoints {
lettersRegex := regexp.MustCompile(letters)
totalPoints += len(lettersRegex.FindAllStringIndex(word, -1)) * points
}
return totalPoints
}
fixed with v0.4.3
Solution: https://exercism.io/mentor/solutions/c210bad335ce46f3b3b1cbaf50901736