The player has between one to seven tiles in their rack which are known as RACK TILES:
There are also tiles on the board for everyone to use which are known as BOARD TILES:
The rules of Scrabble let the player place tiles together in a single row or column. We will refer to sections of a row or column as SCOPES:
This one shows the minimum amount of characters for a proper Scrabble input. It must have at least one rack tile, one board letter tile, and one open board tile.
This one shows the maximum amount of characters for a proper Scrabble input. There can only be up to 7 rack tiles and the scope can be up to 15 tiles.
This last example shows a special case of using a blank rack tile (signified by the "?"). A blank rack tile can represent any letter when being placed and there are only 2 blank tiles available to all players.
As an example, let's assume we start with this scope:
Each scope within this starting scope will be found in this order:
The start of the scope begins at the leftmost tile. It will check every ending tile in decreasing order. The start will then move to the right one tile and check each ending tile again.
To find all possible solutions for a scope, we will need to follow this pseudocode:
FOR every word in words array IF word could be fit in the scope ADD to possible words array FOR every word in possible words array IF word contains letters in rack ADD to scrabbles array
Add this code to the
The code first converts the rack from a string into an array (we can easily delete items from arrays but not strings). Ignoring board letters, we then go through each new letter in the word and check if it is inside the rack array. If it is, then we remove it from the array and move on.