Calculates only by letter points
import "strings" var LETTER_POINTS = map[byte]int{ 'a': 1, 'b': 3, 'c': 3, 'd': 1, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10, } func CalculateScrabblePoints(word string) int { points := 0 if len(word) == 7 { return 50 } lowerWord := strings.ToLower(word) for _, letter := range lowerWord { points += LETTER_POINTS[byte(letter)] } return points }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Calculates only by letter points