Category Archives: Software

An Alternative to “Hello world!”

There’s an appreciable risk that this post may be considered sacrilegious within the programming world.  If there’s one thing, even  just one tiny, single thing, that every programmer knows about teaching programming, it’s that the first lesson should be how to output the string, “Hello world!”  (There’s some dispute as to whether the ‘w’ should be capitalised but the ‘!’ is entirely necessary.)  How heretical would it be to suggest that, not only is this probably not the best place to start, but that a better alternative can be found by turning around a bottle of shampoo?

ShampooBottle Continue reading


Maths and Programming Working Together

When the Four Colour Theorem (FCT) was finally ‘proved’ in 1976, it upset a lot of mathematicians.  It was the first significant mathematical concept to be proved with a good deal of help from a computer and, for many, that didn’t make it a real proof.  Although we’re largely (maybe not entirely) OK with it now, the objections at the time weren’t just theorists’ snobbery.  At the heart of it all were some fundamental questions about the role a computer could or should play in formal logic.

Essentially, the FCT says that the maximum number of different colours needed to colour a map, so that no bordering countries are the same colour, is four.  (Colours can touch at a point but not at an edge.)  It’s easy to show that five will always do the trick and, in fact, most normal maps only need three.  However, certain types of map certainly seemed to need four so was four always enough? Continue reading


How to Write a Really Bad Program

(A case study in bad and good algorithm design.  Hopefully, a bit of fun for anyone in a programming frame of mind, but also serving as a useful reference for the ‘Are There Any Hard Problems?’ post that follows.)

In ‘A Scandal in Bohemia‘ (Arthur Conan Doyle, 1891), Holmes and Watson discuss the difference between seeing and observing“You see, but you do not observe [Watson]. The distinction is clear. For example, you have frequently seen the steps which lead up from the hall to this room.”  “Frequently.”  “How often?”  “Well, some hundreds of times.”  “Then how many are there?”  “How many? I don’t know.”  “Quite so! You have not observed. And yet you have seen. That is just my point. Now, I know that there are seventeen steps, because I have both seen and observed.”

Who knows; perhaps, if they hadn’t moved on to discuss more pressing issues (that King of Bohemia has a lot to answer for), Holmes may have set Watson something a little more interesting:  “How many of these steps do you generally take in a single stride, Watson?”  “I suppose one or two, Holmes, it varies; never three. Sometimes I take different combinations of one and two steps as the mood takes me”  “Excellent, Watson; another challenge! So, taking these steps one or two at a time, in any combination you wish, how many different ways are there of climbing the seventeen steps?”  “Well, I’m quite sure I don’t know, Holmes; rather a lot, I would imagine!” Continue reading