Saturday, May 16th, 2009

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.)

(1 comment | Leave a comment)

Sunday, May 3rd, 2009

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 indulge in sports references (which I'm useless at) and tend to be a little repetitive, they have nice puns and they have a good variety of difficulties (they follow the US convention of easiest ones on Mondays and hardest ones on Sundays). Incidentally, the repetitiveness seems common to US crosswords — perhaps a side-effect of the US grid style?

However, I like the Guardian's crosswords a lot too. Unlike the Chronicle, they have cryptics, which I like to try my hand at from time to time. The problem is that the Guardian crosswords are only available online via an annoying Java applet or as PDFs. I managed to work around this using the fact that the input to the Java applet is encoded on a screen-scrapable HTML page, and wrote a tool to convert the HTML to the AcrossLite .puz format. To get the reulsting files to work in Xword, I had to write some patches to support British-style grids.

gtrans

A crude command-line client for translate.google.com.

debri

Like debi, but installs packages to a remote host over SSH. Useful when cross-compilating for Debian-based embedded systems.

(4 comments | Leave a comment)

Sunday, January 6th, 2008

Internet cloud

This is my new favourite depiction of the Internet, courtesy of RFC 908:

An ASCII art diagram that uses a cloud of assorted non-letter characters to represent the Internet

Given that the Internet is a bit like a game of Robot Finds Kitten, it only makes sense that it look like one. Alternatively, it's reminiscent of the swearing in Asterix, which is also appropriate.

(2 comments | Leave a comment)