X

# L'Unix programming contest

if two programs work, how do we decide which is better?
Written by Paul Murphy, Contributor
Last week's discussion about development languages was, I thought, both wide ranging and interesting. In particular I ended up trying to understand to what extent, if at all, organizational structures are generally conflated with development issues - meaning that you can't tell the chickens (organizational assumptions) from the eggs (ideas about development methods).

Notice in saying this that I'm explicitly differentiating programming (coding) from development (creating a working application from requirements to deployment) and suggesting that organizational structures currently in wide use to support development may be influencing our perceptions about programming.

On the fun side, however, I was struck by the depth of the disagreement among people commenting on Friday's bit about coding as art. One of the issues there, it seems to me, is how, or on what basis, you can judge whether coding is elegant - and, for that matter, whether the problem addressed lends itself to elegant solution.

To pursue that a bit I've listed three small programming challenges below - only two of which I currently know how to address with anything other than a brute force approach:

1. list and count, for small n (0 < 100), all paired anagrams which can be constructed from the positive integers less than n spelled out as words, such that the sum is the same on both sides of the re-ordering. e.g. eleven + two = twelve + one.

2. print the sum of the square roots of an arbitrary real valued vector (assume lengthof(n) < 1000) together with the upper and lower bounds on the estimate.

3. produce a table giving the complete n-way crosstab for three PostGresSQL tables, t1, t2, and t3 with the same primary key. (Assume millions of rows, n (= total columns - 2) < 36).

What I'd like to do with these is ask two questions:

1. is the problem well stated and, if not, how would you clarify it? e.g. disallow blobs? restrict number use to once only?

2. how would you judge the resulting programs to determine a winner if this were a programming contest?

There are some givens: programs have to run on one of Solaris, Linux or BSD; entries are automatically public by virtue of being published as comments to an eventual blog opening the contest; and programs cannot use libraries or other materials for which users have to pay or undergo an otherwise onerous loading process.

Beyond that what I'm most interested in are problem restatements (and the reasoning behind those) and criteria for judgement - if two programs work, how do we decide which is better?

If we get good answers - leading to properly written challenges and a consensus basis for judgement by, say, Friday Oct 13th - we'll turn it into an actual programming contest and I'll buy some appropriately cheap (0 < \$25) and arbitrary prizes - perhaps just more or less randomly picking things off ebay for delivery to the winners in each of the three challenges.

Editorial standards
ZDNET
Notice:
We've updated our Terms of Use, effective immediately. By continuing to use the site, you agree to the updated Terms of Use.