Function Repository Resource:

ScrabbleScore

Source Notebook

Find total points scored by a word using Scrabble tiles

Contributed by: Joseph Brennan

ResourceFunction["ScrabbleScore"]["word"]

computes the points scored for playing "word" with Scrabble tiles.

Details

ScrabbleScore assumes the letter values and distribution of a standard English-language edition Scrabble game. Other language-versions have different letters and letter distributions. This is not yet considered here.
Input can be in uppercase or lowercase. "?" represents a blank tile.
English-language editions of Scrabble contain 100 tiles, in the following distribution: 0 points: 'blank' indicated by ? x2 1 point: E ×12, A ×9, I ×9, O ×8, N ×6, R ×6, T ×6, L ×4, S ×4, U ×4 2 points: D ×4, G ×3 3 points: B ×2, C ×2, M ×2, P ×2 4 points: F ×2, H ×2, V ×2, W ×2, Y ×2 5 points: K ×1 8 points: J ×1, X ×1 10 points: Q ×1, Z ×1
ResourceFunction["ScrabbleScore"] returns a single integer indicating the total points scored for a valid input.
The awarded score assumes the limits on each character shown above. A zero value, constitent with a blank, is given for each instance of a character above the limit. When the number of possible blanks is exceeded, an error is returned instead of a score. For example, "pizzazz" has four "z" characters more than the number of "z" tiles and blank tiles combined.

Examples

Basic Examples (2) 

Find the number of points scored by the word "scrabble":

In[1]:=
ResourceFunction["ScrabbleScore"]["scrabble"]
Out[1]=

Blanks are denoted by '?' characters. They contribute zero points to the total:

In[2]:=
ResourceFunction["ScrabbleScore"]["?ylophone"]
Out[2]=

Scope (7) 

A word may contain more of a particular letter than the letter distribution permits, requiring the assumed use of one or two 'blank' tiles. Here "recalcitrance" contains three Cs but the tile bag contains only two, requiring one 'blank' C that contributes zero points to the total:

In[3]:=
ResourceFunction["ScrabbleScore"]["recalcitrance"]
Out[3]=

Explicitly giving a blank gives the same score:

In[4]:=
ResourceFunction["ScrabbleScore"]["recalcitran?e"]
Out[4]=

Here "zzz" contains three Zs but the tile bag contains only one, requiring two 'blank' Zs. The score is therefore 10 + 0 + 0 = 10:

In[5]:=
ResourceFunction["ScrabbleScore"]["zzz"]
Out[5]=

The word must be 15 characters or less in order to fit on a standard Scrabble board:

In[6]:=
ResourceFunction["ScrabbleScore"]["EXTEMPORANEOUSLY"]
Out[6]=

Aside from blanks, non-letter characters are not allowed in the word:

In[7]:=
ResourceFunction["ScrabbleScore"]["red-hot"]
Out[7]=

Here "zigzagging" contains two Zs and four Gs but the tile bag contains only one Z and three Gs, requiring a 'blank' G and Z that each contribute zero points to the total:

In[8]:=
ResourceFunction["ScrabbleScore"]["ZIGZAGGING"]
Out[8]=

Here "knickknack" contains four Ks but the tile bag contains only one. There are not enough 'blanks' to construct this word:

In[9]:=
ResourceFunction["ScrabbleScore"]["KNICKKNACK"]
Out[9]=

In a similar way, a maximum of two '?' symbols, indicating blanks, are allowed in the input:

In[10]:=
ResourceFunction["ScrabbleScore"]["?l?m?nt"]
Out[10]=

Possible Issues (1) 

Given that Scrabble word lists are protected by copyright, there is no way to verify that an input is a valid Scrabble word. This means that the 'score' is still found for a nonsense input provided it can be constructed, is 15 characters or less, and contains no special characters:

In[11]:=
ResourceFunction["ScrabbleScore"]["XUJQFL"]
Out[11]=

Neat Examples (1) 

Highest scoring Scrabble word:

In[12]:=
ResourceFunction["ScrabbleScore"]["OXYPHENBUTAZONE"]
Out[12]=

Publisher

Joseph Brennan

Requirements

Wolfram Language 14.0 (January 2024) or above

Version History

  • 1.0.0 – 07 August 2024

Source Metadata

Related Resources

Author Notes

Possible improvements include a "Language" option to incorporate more than just the English letter distribution.

License Information