Category: Intermediate

In our last post we showed how to recurse our anagram solver in a function. Next we will optimize that function with a well known technique that is very easy to implement: memoization. First let’s look at our current solution, which very, very thoroughly searches through all possible anagrams:

In my last post about anagram solving I talked about how to set up a decent way to get anagrams out of a string of letters. This time I’m going to take it a step further and refactor the code into a recursive function so that you can find anagrams beyond the current three word limit.

An anagram is a fun bit of wordplay that rearranges the letters of one phrase into another. For example, Andrew Tremblay is an anagram of Amble, Wander, Try and Apple Macintosh rearranged is Laptop Machines. Does making a program that finds all the anagrams of your name sound like fun? Well then keep reading!