HOME > > MAIN "PROGRAMMERS" PAGE

Programming can be fun!


Here are two ideas for you which might develop into enjoyable exercises for programming classes or clubs.

For either one, you might find my text file full of legitimate three letter words useful. It comes with my program "Word Wheels", which you can download (and use, free) from my freeware/ shareware site.

First idea....

I'm told that the following letters can be arranged in a square which has a common English word on each row, in each column, and two more on the diagonals. The letters: T W O Y E A R S D. (Thank you, National Public Radio (USA) for this puzzle). The challenge is to write a program to facilitate (or by itself) find the solution.

Second idea....

This exercise comes in two parts. For weeks (months?) the participants develop programs for decoding material which has been encoded according to the following procedures. On The Big Day, the participants gather in a computer lab, bringing the with them their programs. The organizer brings a large number of encoded messages, each encoded differently. Everyone tries to decode as many messages as possible in the time allowed. Presumably the participant with the best program (and the best mind) will decode the most. Everyone should have a bit of fun at least.

(There are two free programs on offer, see below, to help you with this)

With the coding method proposed, the following schemes can be applied to the decoding process, particularly if the participants are given quite lengthy encoded messages to analyze. The encoded messages should almost certainly be provided to the participants in machine readable form, even if this means providing programmers of limited skill with shells of programs which have the "read the file" stuff already done. The participants can bring their imagination to bear in trying to achieve a happy balance between having the program do the decoding and using the computer primarily as an efficient piece of "magic paper" on which various guesses by the human can be quickly applied to the encoded message. The winning the solution will also probably have given careful consideration to how the decoding process is displayed. Again, this is a very open-ended exercise with many solutions possible at many levels of programming skill.

Available ploys:

a) The most common letter in the coded message probably stands for "e". The second most common letter probably stands for "t", and so on.
b) Common pairs (and triplets) of letters can be counted, and their positions in words are revealing. ("th" is usually easy to find, both as a part of "the", "then", That", etc, and also as whatever letters stand for "th" will often occur at the ends of words.)
c) Any single letter should stand for "a" or "i".
d) Words almost always contain a vowel.
e) While there are many words in English, only a few of them are used frequently.
f) Most importantly: ETC... what can your participants think of?

Proposed rules:

Make up your own rules by all means, but I thought some of the following are worth considering:

The code will be a simple substitution code. By this I mean, for example, that every e in the original message becomes, say, a w; every t becomes a g, and so on. For a simple exercise, you could decide to use a simple "shift" code, e.g. a in the original becomes c, b becomes d, c->e, d->f, etc... y->a, z->b.

Before it is encoded, the message will have all capital letters converted to small letters.

Only letters will be encoded. Leaving the location of spaces clear greatly harms the effectiveness of the coding system, but that is not the point. Something that allows the programmers a variety of ways to attack problem IS the point. You can of course make other rules, but it will be important that all participants clearly understand the details of the aloud character set. You will save yourself grief if you stick to printable characters.

You probably should be explicit about the length of messages the participants will encounter.

It is not entirely necessary, and it would involve some programming, but it might help everyone see the competition as "fairly" conducted if you provide something like a check sum with each encoded message. The participants would be told how to incorporate "check the check sum" code into their programs. With this on the Big Day, squabbles about whether something had "really" been decoded could be avoided.

If your participants are sufficiently sophisticated, it might be worth downloading the text of two or three novels from the Internet and stipulating that all of the encoded messages will be passages from those novels. You would make the novel's texts available to the participants. They could then analyze that text for things like common words with double letters in the middle, e.g. soon, food.... and other "fingerprint" words to use in their decoding schemes.

Please let me know if you try (or have tried) anything remotely like this. I'd be especially appreciative of copies of whatever rules you used, so long as you don't mind the passing them along for the benefit of others. Do you know of any other places on the Web where ideas like this are posted?

Above all: Create an event which will be fun for your participants, and stretch their brains at the same time!

Free software related to coding challenge:

Each of the following links will cause download of the file described. They come to you unzipped. They play by the "simple" rules proposed above: All capital letters converted to small, only letters encoded, only letters substituted for letters. Unprintable characters are stripped out (which messes up paragraph breaks, but, hey! It's free!

The first will convert a simple .TXT file into an encoded file, using simple substitution. It also adds a checksum to the end of the file. IT WILL WRITE TO YOUR DRIVE (but it won't overwrite existing files without permission. If you take, say, Demo1.txt and run it through the encoder, you gain a file called Demo1.enc (For "ENCoded")
Simple encoding program

The next will display an encoded file and allow you to enter your guesses as to the correct substitutions. Try it! (You'll have to encode something with CD37 first). It will show the competition participants a crude example of what they are going to build. It checks what you have produced, and reports when the full decode appears (from the checksum) to have been accomplished.
Simple decoding program

Lastly- If you're a glutton for punishment, download the following, unzip it, and you can extend CD40 (if you program in Delphi.) (It will be of no use unless you have the Delphi compiler.) (I think you only need three of the files, but it was easier to post them all than to look up the minimum!)
Delphi source for simple decoding program
Click here to go my main "Programmers" page.
Click here to go to the main page of the author of these ideas.


Here is how you can contact this page's editor.
Why is there a script and hidden graphic on this page? I have my web-traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try one, check out their site. Neither my webpages nor my programs incorporate spyware. If the page has Google ads, they also involve scripts.