Dafydd (dgh) wrote,

Futility Closet, ever edifying, notes that the word “ravine” is reversed when rot13 is applied. Are there other words that have the same property? We can easily find out with a bit of code:

> import qualified Data.ByteString.Char8 as B
> rot13 = B.map (toEnum . r . fromEnum)
>    where r c | (65 <= c) && (c <= 90)  = (c - 65 + 13) `mod` 26 + 65
>              | (97 <= c) && (c <= 122) = (c - 97 + 13) `mod` 26 + 97
>              | otherwise = c
> main = B.interact (B.unlines . filter (\x -> rot13 x == B.reverse x) . B.lines)

The answer: not many. Running this on /usr/share/dict/words yields a paltry 12 words; all of which, “ravine” excepted, are four letters or less. We get slightly better results running it on the 390,583-word british-english-huge file from 12dicts (which I keep installed for exactly this sort of tomfoolery). On the other hand, some of the extra words are quite obscure. The full list:

an anan cherup fans fobs fs gant gnat grivet na nana ravine re rebore rive robe serf tang thug uh

(This post can be compiled by saving it as a .lhs file and running ghc --make on it.)

Tags: haskell, pgo, wordplay

  • removing cartridge bearings

    Finding advice on removing a cartridge bearing from a bicycle wheel proved surprisingly difficult recently. Even a fairly recent and comprehensive…

  • Breakdown: Markdown for presentations

    Recently I've been giving a few talks, and anticipate giving several more in the near future, and have been getting annoyed at how time-consuming…

  • recent hacking

    crosswords I enjoy crosswords very much, and for a while I've been loading the free Houston Chronicle crosswords in Xword. Although they…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded 

  • 1 comment