I've been playing the Android game Wordiest recently, which requires making two words out of a hand of letters given to you. Although it might take the fun out of the game, I made a tool that comes up with the longest words that can be made out of a given set of letters. That's what Words, Please is: a Perl script to find all words in a dictionary containing specified letters. A live demo is available at http://davepagurek.com/wordsplease.
WordsPlease works with text files with one word per line.
1. Create an instance of WordsPlease
- Directory: The directory with your dictionary text files
- Word limit (optional): If a limit is specified, WordsPlease stops after finding that amount of words in whatever order they were found in.
- Time limit (optional): If a limit is specified, WordsPlease stops looking after the specified number of seconds.
use WordsPlease; my $wordsPlease = new WordsPlease("dictionaries", 1000, 3);
Word list text files can be downloaded online from your source of choice. The live demo uses the SIL International list.
2. Get an array of matched words
- Exclusivity (optional, default is 0): If 1, no letters not listed can be in the word
- Match Quantity (optional, default is 0): If 1, only as many of each letter as appear in the letters string can be in the word
my @matchedWords = $wordsPlease->wordsWith("abcde", 1, 1);