Programming mini-project: a letters and words game (18th September 2017)


An extra edition of our bulletin to celebrate National Coding week with a programming mini-project!

This issue of the bulletin includes a mini-project. If you want your fellow coders or our tutors to see your solution, upload your solution to a code repository such as Github and post a link in a reply below.

We will also be uploading our solution next week.

A letters and words game

There are many letters and words games, from classics like Scrabbles, to modern ones like Spelltower, from slow-paced like crosswords, to frantic like bananagrams.

The game you will be programming is a slow-paced word-finding puzzle. In this game the player is presented with a list of letters (for example, ‘e’, ‘h’, ‘o’, ‘s’, and ‘u’) and must find words built from these letters (“house”, “shoe”, “sue”, “she”, etc.).

In its basic form, the program operates as follows.

  1. It prints out the list of letters and the list of words. The list of words is hidden (they are shown as asterisks or underscores) until they are guessed.
  2. It reads a word from the player.
  3. If that words is valid (if it exists and is only composed of available letters), then the word is considered guessed.
  4. The game start again from 1) except if there are no more words to guess.

If you write it in Python, you can use the terminal as an interface: print things to the terminal and read things from the terminal. If you write it in Javascript, you can make a simple page with a text input form: you print things on the page and read things from the form.

That’s the basic idea! Below are an example (to get a better idea of what the player sees and does), some useful links to word lists and some bonus features (ideas of how to extend your program).


The program shows:

____  ____  ____  _____  _____  ______  ____
e m m r s u

And the user types:


And the program replies:

____  ____  ____  _____  _____  summer  ____
e m m r s u

And the user types:


And the program replies:



Useful links:

To check that a word is a valid English word, you can use on of the online word lists:

No two lists are the same… Some include too many words (e.g., acronyms or technical terms) and others not enough (e.g., recent words). Try to find a list of words that works for you, but don’t focus too much on it: it’s easy to change afterwards.

Bonus features:

If you finish the challenge quickly, if you want to spend more time on it, if you are looking for more, here are some features that you can add to your program.

  • A way for the player to get the solution: when the player gives up, show them a list of all the words they didn’t find.
  • A way for the player to get hints: when the player is stuck, reveal a single letter in each word.
  • Links to the definition of each word (e.g., using wiktionary).
  • Only use words longer than 3 letters.
  • A nice interface! For example, when the user starts to input some letters, they can be shaded from the letters list.
  • A scoring system: more points for longer words. And you can also add a timer.

Programming Challenge: letter grids

You can find two solutions on the following project:

The first solution is in Python. It loads a file to read a list of existing English words. It instantiate an engine to run the game. Then it starts the main loop: reading from the terminal, testing if the word is valid and then printing the result.

The second solution is in Javascript. It loads a list of words by doing a request. Then it waits for the player to submit an answer in the HTML form. When this happens, it intercepts the request in Javascript, checks the answer and updates the display.