The Unjumbler

Scrambled words are hard for humans to deal with, though there are humans who have an uncanny knack for unscrambling them quickly. If you look at the scrambled word clabena and can unscramble it in your head in a few seconds, you're one of those lucky ones. Most of the rest of us would end up writing down lots of more or less random arrangements of the letters (canebal, neablac, acalenb, …and so on) hoping that we stumble across one, say balenca, close enough to the answer to make us see it. When no such inspiration strikes, we have to try a lot of permutations—because there are, to be exact, n! of them for any n-letter word. For clabena, that's 7! = 5040.

The job is a little easier for a computer because it can spin out all the ...

Get Sams Teach Yourself Ruby in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.