The most merciful thing in the world is the inability of the human mind to correlate all its contents.
H. P. Lovecraft
Foucault's Pendulum

Some rights reserved by Feuillu (http://www.flickr.com/photos/feuilllu/) These weeks, with much pleasure, I have been reading Umberto Eco's Foucault's Pendulum. The writer truly knows a lot about history, philosophy, literature, different cultures and is very erudite. So besides enjoying the good plot, reading Foucault's Pendulum learns me a lot. However, on one thing the writer is a bit off. In the beginning of the book the main person tries to break into a computer by writing a (inefficient) computer program which generates anagrams of 'JHVH'.

Accidentally two weeks before reading this passage I wrote for my DND group a small program which solves a similar question in general. Since this group is too lazy to solve puzzles, I put the program on line; it is called rotx. Perhaps someone can make good use of it. It finds all rotx puzzles (with x = [1..25]) which deliver again a known word.

So, for example layout is the 'encrypted' version of fusion (rot6, so a->h, b->i, c->j, d->i, e->k, f->l, etc.), curly -> wolfs, arena - river, etc.

In dutch some solutions are urnen -> lieve, opaal -> hitte, knijp -> bezag and kerk->gang.

To use rotx you need a wordlist, for example as generated by aspell:

   aspell --lang=en dump master | ./rotx - > rotated.txt

The output (in the example above copied to rotated.txt) contains all rotated words which can also be found in the original wordlist..

The first incarnation of the program was in bash/sed/tr and awfully slow. (I had to try though, "No premature optimization!"). It should take two weeks to process a 1.5 MB English wordfile. (Eco's Basic script should take what, years??). Enter C++ and STL. The direct approach (rotating all words through the entire alphabet and looking all results up in the original list) should still take around 20 hours. So I cooked up an algorithm which uses more memory, but finishes in approximately 15 seconds on my old and crusty AMD duron 850!

The source can be found at /downloads/rotx.cc.html.

Posted by jochem on 2005-05-22, last update on 2005-05-22