Counting Letters for Fun!

How do you crack secret codes? One of the oldest algorithms is called frequency analysis. It was invented in the 9th century by a Muslim scholar. It led to the execution of a Queen, has played an important part in detective stories, and also had a role in the design of the game of Scrabble.


Frequency analysis was invented by Al-Kindi as a way of cracking codes. Al-Kindi was a wise teacher, a scholar, who lived thousands of years ago. To do frequency analysis you take lots of normal writing and count how often each letter appears – the frequency of the letters. For example, in English, E is the most common letter. Work out how common each letter is and you have enough information to crack simple secret codes. You just count how often each letter appears in the secret message you want to crack. You then compare it with the order based on the known count for letters in English.

Queen Elizabeth I caught her cousin Mary Queen of Scots plotting against her. How? Her spymaster Walsingham read the coded letters that Mary had written. He used frequency analysis. As a result Mary was convicted of treason and executed.

Sherlock Holmes, of course, was a master of frequency analysis. In the 1903 story “The Adventure of the Dancing Men” he uses it to solve a case. Sir Arthur Conan Doyle who wrote Sherlock Holmes wasn’t the first author to use it in a story. American writer Edgar Allan Poe based a short story on frequency analysis in 1843. Poe had set a challenge in a magazine for people to send in secret messages – that he then cracked using frequency analysis. At the time, his super code cracking skills gave the impression he had near supernatural powers. The way it was done was then described in his story “The Gold Bug”. This story made frequency analysis famous, it was not just for spies now.

Game On!
In the 1930s, Architect Alfred Mosher Butts, hit on the idea of a new game that combined crosswords and anagrams. Both were popular at the time. He called it Scrabble. However, he had two problems to solve. How many of each letter should the game have and what value should each letter be for scoring? He turned to frequency analysis! He used the front page of a newspaper, the New York Times, to help him work out how common letters were. However, he did not quite keep to the pattern that he worked out. He included fewer letter Ss so that the game wasn’t too easy because of plurals.

Now lots of people do frequency analysis just for fun every day, solving code cracking puzzles in magazines, puzzle books and papers including the New York Times!

Fun to do: Write a story

Write your own story that depends on frequency analysis.

Fun to do: Crack it!

Decrypt our computing joke using frequency analysis

Cartoon Animal Eyes Under Big Stone

More Spy Stuff

abitofcs4fn3coverRead Issue 3 of A Bit of Cs4fn