News & Articles:

Kata: Scrabble

We like word games where you score points depending on the values of letters, and we often play on-line. Which is why we wanted a program to display the best word to make from a collection of Scrabble letters.

Introduction

A rack of letters in Scrabble can contain up to seven tiles. A tile either bears a letter, or else is blank, meaning that it can be used to replace any single letter. Each letter is allocated a score, except for blanks which score nothing. It is often useful to have some convenient means to determine the best word that can be made from a rack of letters.

Task

Allow the user to enter the contents of their Scrabble rack. They will enter letters and a ? to denote any blank tile. Then determine the best word (that is, the one that scores the highest) that can be made from those letters. There can be up to seven letters (including blanks) entered.

Only certain words are valid in Scrabble (proper names are not allowed, for example), so a special dictionary is needed for this task. A list of valid Scrabble words can be found on the Internet, for example  at http://www.freescrabbledictionary.com/sowpods.txt.

Ignore the complexities of “Double Word” score squares and the like. But remember that 7-letter words atttact a 50 point bonus.

The program should also validate that the rack of letters entered could genuinely occur (for example, there is only one Q tile, so a rack cannot have two (although words with two Qs would be OK if the rack contained a blank).

The distribution of letters, along with the corresponding scores, can be found here: http://en.wikipedia.org/wiki/Scrabble_letter_distributions.

Creative Commons Licence
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Posted in Technical

Tags: , ,