Sha256: 362938d7f4198346e249f5b3c9071b2269182a4601eb9fc1e35ffbd432c0fce7

Contents?: true

Size: 503 Bytes

Versions: 122

Compression:

Stored size: 503 Bytes

Contents

package scrabble

import (
	"strings"
)

var letterValues = map[rune]int{
	'a': 1, 'b': 3, 'c': 3, 'd': 2, '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,
}

// Score computes the number of points that a word is worth.
func Score(word string) int {
	word = strings.ToLower(word)

	sum := 0
	for _, letter := range word {
		sum += letterValues[letter]
	}
	return sum
}

Version data entries

122 entries across 122 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.179 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.178 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.177 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.176 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.175 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.174 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.173 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.172 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.171 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.170 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.169 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.167 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.166 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.165 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.164 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.163 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.162 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.161 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.160 tracks/go/exercises/scrabble-score/example.go