The Plenitude of Arboreal Beauty

The author published this entry on Thursday 07 August, 2008 at 9:00 pm. It's been filed in the Computer Sciencecategory

Self-documenting code contest

There’s a really neat contest going on as a response to the Obfuscated C contest. The goal is to write a piece of code that solves a particular problem in such a lucid manner that, without comments, lay people would understand your solution. The problem:

Write a program that generates all two-word anagrams of the string “documenting”. Here’s a word list you might want to use: http://pragdave.pragprog.com/data/wordlist.txt.

This Python one-liner is a sufficient solution (isn’t it ironic that the rules of the self-documenting code contest are under-specified?):

[(word1, word2) for word1 in wordList for word2 in wordList]

More seriously, here’s my beautiful Haskell solution. Haskell can be very clean, concise, and elegant if you know the rules, but I’m pretty sure the list comprehensions and higher-order functions would confound the uninitiated.

The Conversation {1 comments}

  1. Danny 11 August, 08 @ 8:45 am

    Hi David,
    Thanks for your comment on my blog: http://techismything.blogspot.com/. I’ve removed the article that you were offended by, and want to clear up that the article ‘Appreciating Windows’.

    Please have a look at my latest post, to clear up just what I meant. I didn’t have the intention of crediting anyone else for your hard work.

    Thanks,
    Danny

Leave Your Own Comment

You can follow any responses to this entry via its RSS comments feed. You can also leave a trackback if the inclination is there.

If you're looking for something specific then give the search form below a try:

RSS Wordpress Grady (theme) Valid XHTML Return to the Top ↑