Word Match

Word Match

Dr. Phillip M. Feldman

1. Introduction

I've created a word match solver that one can either run online or download to one's computer to run locally. Such a solver is useful for the game of hangman, and can also be handy when one is stumped while playing or creating a crossword puzzle. (For crossword puzzles, one would probably want an unabridged spelling dictionary that includes a wide variety of proper nouns. If anyone can supply such a dictionary, I will be happy to post it). I also have an online game, based loosely on hangman, called Word Match.

With both the solver and the game, information about allowed letters and their locations is specified via a template and a list of excluded letters. The template is typically a sequence of letters and underscores, but may also contain certain other symbols that are not used in hangman. The following non-letter symbols are permitted:

Excluded letters may appear in the template. When this happens, the interpretation is that excluded letters may appear in a matching word only in positions corresponding to those where they appear in the template.

When using the solver, it is sometimes more convenient to specify allowed letters rather than excluded letters. This can be done by typing a caret (^) at the front of the list of excluded letters. If, for example, one specifies _e_ as the template and ^gnt for the list of excluded letters, the code will produce the following matching words: get, net, and ten.

2. Online Word Match Solver

To run word_match.py online:

  1. Enter a template into the first box. If you provide a template that allows for too much flexibility, e.g., one that uses only the asterisk and underscore characters, without any letters, you will get a large number of matches.

  2. Press the tab key to advance to the second box and specify any excluded letters (letters that must not appear in matching words). If there are no excluded letters, press the Delete key to clear this field.

  3. Select one of the two spelling dictionaries.

  4. Click on the yellow button.

  Template:      Excluded letters:     

Small spelling dictionary Large spelling dictionary

Hide solutions (report only the number of solutions)

3. Word Match (Vocabulary-Building Game)

3.1 Introduction

In this variation on the game of hangman, the goal is to find all words that match the template provided by the computer. Note:

3.2 Play Word Match

0 (ages 5-7)   1 (beginner)   2 (easy)   3 (intermediate)   4 (challenging)   5 (hard)   All/None  



Scores: Last:    Last 3:    Last 10:    Last 30:    Last 100: 



4. Downloadable Word Match Solver (Python Script)

To run the Python script on your computer:

  1. Make sure that you have a working installation of Python on your computer. See the section in my Python material entitled "How to Get Started".

  2. Verify that a spelling dictionary file containing one word per line exists either in the folder containing word_match.py or one level higher in the folder tree.

  3. Verify that the file console_input.py exists either in the same folder as word_match.py or in a folder specified via the PYTHONPATH environment variable.

  4. Depending on what operating system you are using, open a Windows or Linux command prompt and make the folder containing word_match.py the current folder.

  5. To run word_match.py using the default spelling dictionary 'large.txt', and to be prompted for other inputs, issue the following command:

       python word_match.py

    To run word_match.py with a non-default spelling dictionary, issue a command of the following form:

       python word_match.py template excluded dictionary

    where 'template' is the hangman template, 'excluded' is the list of excluded letters (enclosing quotes are optional unless the list is empty, in which case the quotes are required), and 'dictionary' is the name of the dictionary to be used, e.g., 'small.txt'.

Download word_match.py

Download console_input.py

5. How the Word Match Solver Works

The Python code for this solver is surprisingly simple. For those interested in programming, the script operates as follows:

  1. The word template is converted into a simple regular expression (regex), and the excluded characters are stored as a Python set.

  2. The following operations are performed for each word in the designated spelling dictionary:

  3. The list of matching words is displayed.

(An alternative approach would have been to formulate a regex that incorporates the information about the excluded characters, rather than performing two separate tests). A wide range of word puzzles can be solved using regex's; for more on this subject, see my page Solving Word Puzzles via Regular Expression Matching.

6. News Items

29 Dec., 2018: There are now 1,000 Word Match puzzles.

24 Oct., 2015: There are now 900 Word Match puzzles.

1 Jan., 2014: I've completed a scrub of the database to resolve issues created by recent changes to the small spelling dictionary, and also fixed an issue with scoring.

7. Further Reading

1. http://en.wikipedia.org/wiki/Hangman_(game): Wikipedia article on hangman

2. "25 Best Hangman Words" (an analysis of the game of hangman)

Last update: 27 Feb., 2022