Under 1% of English words are alphabetical

, posted

386 out of 58,115 English words (about 0.66%) are alphabetical. Words like “abs” are alphabetical, and words like “cab” are not.

For some reason, I’ve wondered for a long time (about a year): how many words in the English dictionary are alphabetical? That is, if you were to reorder all the letters in a word alphabetically, how many wouldn’t change? For example, “abs” and “ghost” are alphabetical and words like “cab” are not.

How many do you think there’d be? I thought the number would be pretty low—my guess was less than 5%.

I’m in the process of learning C, and I figured it’d be faster for parsing 58,115 words. So I downloaded a list of 58,115 English words (link now dead) and got started. I started by writing a function called isAlphabetic, which takes a string of lowercase letters and returns whether it’s alphabetic. I wrote a few tests to make sure it worked, and then I was all done. When I ran it, I got the following output:

386 are alphabetical out of 58114 (0 percent).

I plugged it into a calculator for a little more precision, and got about 0.66%. Lower than I expected!

I figured that a version in a scripting language would be slow, but after I saw how trivial it was to write, I made a CoffeeScript version to see. When I ran it, it was noticeably slower, but it still took under a second and gave me the same result.

After thinking about it at it, 58,000 words isn’t that many; I should’ve realized that it was okay to use a slower language. I also learned a bit more about C. And most importantly, I put to rest my question: there are only 386 alphabetical words.

Update: This has now been posted as a challenge on the dailyprogrammer subreddit. Go there to see other solutions!