Words, Please

April 19, 2014 View Words, Please View Source on GitHub

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 https://www.davepagurek.com/wordsplease.

Input

WordsPlease works with text files with one word per line.

Usage

1. Create an instance of WordsPlease

Parameters:

  1. Directory: The directory with your dictionary text files
  2. Word limit (optional): If a limit is specified, WordsPlease stops after finding that amount of words in whatever order they were found in.
  3. 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

Parameters:

  1. Letters
  2. Exclusivity (optional, default is 0): If 1, no letters not listed can be in the word
  3. 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);