Build a recursive word finding algorithm with Python - Part 1

by Dan Duda


  • Python 3.x
  • PyCharm Community (optional)
  • A text file of English words
  • Basic Python knowledge


I’ve always loved word games like PopCap’s Bookworm series and Microsoft’s Wordament. I’m also am a programmer and love to hack. So it’s only natural that I’d want to develop a “solver” for word games. A lot of programming concepts can be learned in creating this type of application such as recursion, tree data structures, and optimization. In the following set of tutorials we’ll build an algorithm to find English words based on a set of letters either scrambled like the game Scrabble or grid of letters like in the game Boggle. We’ll start off with a basic data structure and then learn how to better store our data to make searching lightning fast.

Getting a list of words

Before we beging writing any code we’ll need a list of words to use for our lookups. Any large list of words should work but here is one I found, Click here and then click on the “Download” button to download a copy of the words list. If clicking on the “Download” button just brings up the list of words in the browser then just right-click on the list and choose “Save as” and save the “words_alpha.txt” to your computer. This list contains around 479k English words which will really test our algorithm’s performance.

Read More