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

Input can be in uppercase or lowercase. "?" represents a blank tile.
ResourceFunction["ScrabbleScore"] returns a single integer indicating the total points scored for a valid input.
The following options are supported:
"Language""English"the letter distribution used will come from this language's Scrabble edition
"AllowBlanks"Falsewhether to use up to two blank tiles to construct the string
The "?" character can be explicitly included in the string to indicate a blank tile. The "AllowBlanks" option handles only 'extra' blank tiles that may be required to construct the string from the tile distribution.
The "Language" option may be set to the following: {"English", "Afrikaans", "Arabic", "Bulgarian", "Catalan", "Croatian", "Czech", "Danish", "Dutch", "Estonian", "Faroese", "Finnish", "French", "German", "Greek", "Hebrew", "Hungarian", "Icelandic", "Indonesian", "Irish", "Italian", "Latin", "Latvian", "Lithuanian", "Malagasy", "Malay", "Norwegian", "Polish", "Portuguese", "Romanian", "Russian", "Scottish Gaelic", "Slovak", "Slovenian", "Spanish", "Swedish", "Turkish", "Ukrainian", "Welsh"}.

Examples

Basic Examples (1) 

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

In[1]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["scrabble"]
Out[1]=

Scope (2) 

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

In[2]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["?ylophone"]
Out[2]=

In principle, this input could be the valid Scrabble word "zzz", requiring two blank Zs. The score is therefore 10 + 0 + 0 = 10:

In[3]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["z??"]
Out[3]=

Options (4) 

AllowBlanks (3) 

The word "zigzagging" contains two Zs and four Gs but the English tile bag contains only one Z and three Gs. Here, we allow a blank G and Z that each contribute zero points to the total:

In[4]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["ZIGZAGGING", "AllowBlanks" -> True]
Out[4]=

This is equivalent to the following (where "AllowBlanks" is False by default):

In[5]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["ZIG?AGGIN?"]
Out[5]=

Setting "AllowBlanks" to True is allowed even when additional blanks are neither allowed nor required:

In[6]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["ZIG?AGGIN?", "AllowBlanks" -> True]
Out[6]=

Language (1) 

Choosing a different language uses a different character set and tile distribution:

In[7]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["zwölf", "Language" -> "German"]
Out[7]=
In[8]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["niño", "Language" -> "Spanish"]
Out[8]=
In[9]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["jørð", "Language" -> "Faroese"]
Out[9]=
In[10]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["كتاب", "Language" -> "Arabic"]
Out[10]=
In[11]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["\[Epsilon]\[CapitalUpsilon]\[CapitalChi]\[CapitalAlpha]\[CapitalRho]\[CapitalIota]\[CapitalSigma]\[CapitalTau]\[CapitalOmega]", "Language" -> "Greek"]
Out[11]=

Applications (2) 

Some Scrabble editions contain 'digraphs', whereby two characters are treated as a single tile. For example, the Welsh "CH":

In[12]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["diolch", "Language" -> "Welsh"]
Out[12]=
In[13]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["chwe?", "Language" -> "Welsh"]
Out[13]=
In[14]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["chwech", "Language" -> "Welsh", "AllowBlanks" -> True]
Out[14]=

This means that we can have inputs with < 15 tiles, but > 15 characters:

In[15]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["llongyfarchiadau", "Language" -> "Welsh"]
Out[15]=
In[16]:=
Length[StringSplit["ll o n g y f a r ch i a d a u"]]
Out[16]=
In[17]:=
Length[Characters["llongyfarchiadau"]]
Out[17]=

Possible Issues (9) 

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

In[18]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["EXTEMPORANEOUSLY"]

Special characters other than "?" are not allowed:

In[19]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["red-hot"]

The input string cannot contain more than two blank tiles:

In[20]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["?L?M?NT"]

Some input strings cannot be constructed without blank tiles:

In[21]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["QAJAQ"]

Some input strings cannot be constructed, even when blanks are permitted. Here "KNICKKNACK" contains four Ks but the English tile bag contains only one. There are not enough 'blanks' to construct this word:

In[22]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["KNICKKNACK", "AllowBlanks" -> True]

The same error is returned if "?" tiles are explicitly declared and they are still insufficient to construct the input string:

In[23]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["KNICK?NAC?"]

Allowing blanks is superfluous if two are already used via "?" tiles:

In[24]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["KNICK?NAC?", "AllowBlanks" -> True]

The input string must only contain tiles that are present in the tile bag of the selected language:

In[25]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["Käse", "Language" -> "French"]

The "Language" option must be set to a language for which a Scrabble edition exists:

In[26]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["nuqneH", "Language" -> "Klingon"]

The "AllowBlanks" option must be either True or False:

In[27]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["TEST", "AllowBlanks" -> "Maybe"]

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, but still valid, input:

In[28]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["XUJQFL"]
Out[28]=

Neat Examples (1) 

Highest scoring English Scrabble word:

In[29]:=
ResourceFunction[
 "ScrabbleScore", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["OXYPHENBUTAZONE"]
Out[29]=

Publisher

Joseph Brennan

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 2.0.0 – 03 August 2026
  • 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