# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Find total points scored by a word using Scrabble tiles

Contributed by:
Joseph Brennan

ResourceFunction["ScrabbleScore"][" computes the points scored for playing " |

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.

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

In[1]:= |

Out[1]= |

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

In[2]:= |

Out[2]= |

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]:= |

Out[3]= |

Explicitly giving a blank gives the same score:

In[4]:= |

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]:= |

Out[5]= |

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

In[6]:= |

Out[6]= |

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

In[7]:= |

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]:= |

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]:= |

Out[9]= |

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

In[10]:= |

Out[10]= |

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]:= |

Out[11]= |

Highest scoring Scrabble word:

In[12]:= |

Out[12]= |

Wolfram Language 14.0 (January 2024) or above

- 1.0.0 – 07 August 2024

This work is licensed under a Creative Commons Attribution 4.0 International License