Sha256: 1e00cab5e4bf9b5c4491aea05b508ba740b39b4243db19ccdafd354d82875017

Contents?: true

Size: 577 Bytes

Versions: 110

Compression:

Stored size: 577 Bytes

Contents

package scrabble

import (
	"strings"
)

// testVersion tracks the version of the exercise.
const testVersion = 5

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

110 entries across 110 versions & 1 rubygems

Version Path
trackler-2.2.1.56 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.55 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.54 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.53 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.52 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.51 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.50 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.49 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.48 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.47 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.46 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.45 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.44 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.43 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.42 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.41 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.40 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.39 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.38 tracks/go/exercises/scrabble-score/example.go
trackler-2.2.1.37 tracks/go/exercises/scrabble-score/example.go