Guidelines

You might also like to see the tips on solving problems.


Irish Schools Programming Competition How to enter Time Table Rules DCU Computers Sample Problems Previous Competitions IOI


The Basics

Discuss the sample problems with a teacher or a friend. Try to do some of them in the time allowed (i.e. sit down for five hours as if you were in the competition, and do the problem). Practise the file handling commands (as these will be practically the same for every problem). Check the file handling commands in the language that you intend to use, and ensure that you can read a data file and create an output solution file.

Practice under competition rules is important. Writing a program with a time limit is completely different to writing a program that has to be done in a few days.

When writing your program, try to get the easy cases to work first. When this works, try considering unusual input. Lots of people complain that the program would have worked perfectly if it hadn’t been for one tiny bug. So ensure that you test it properly.

File handling

File handling commands are very similar to normal input and output commands. You first open the file, then you use the normal input and output commands, and finally you close the file. BASIC, C and Pascal all have similar file handling commands. Looking at an example. Assume you are asked to write a simple program, that reads a number from the file day1a.dat, and write its square to the file day1a.sol. Then you could write this BASIC program.

When this program is run it will check for a file called day1a.dat (if the file doesn’t exist, the program will generate an error). This should contain a number. The program will read this number, square it, and place the result into a file called day1a.sol. You can create the file day1a.dat with any editor.

Here is an equivalent C program

The File handling commands in Pascal are similar.

Managing time

Writing three programs in five hours is not a particularly easy task. The best way is to decide in advance how you will do the problems. One suggestion that you might consider is when you get the problem sheet, start at problem A. Don’t look at the other problems. Concentrate solely on A until you get it finished. Then forget it. Go onto problem B. Finish it and forget it. If you have time, start problem C, finish it and forget it. Then, if you wish, you can start to go over the problems. Be sure to allow at least 10 minutes at the end to ensure that the files have the correct names, are in the correct directories and that they can compile.

If you are thinking about one problem while you are doing another, you will be much less effective. Because you have been thinking hard about the first problem, it will be hard not to keep going back to it when you are attempting the second problem. One method is to write down your idea about the first problem, and then continue with the second problem. The advantage of writing it down, is that you won’t be afraid that you will forget it, if you stop thinking about it.

Remember the above is only a suggestion. Use whatever method suits you best.

Testing programs

Don’t forget to test your programs. You will be given a file that will contain input data. If you run your program using this data, you should get the sample output. Ensure that this output corresponds exactly with the sample output presented in the question.

You can check this by using the marks program. This will be able to tell you if the output of your program works for that input data. You will be given details of this program at the competition. Note that just because your program works for one set of input data doesn’t guarantee that it works for any other set of data.

Questions

You can only ask questions in the first hour. Normally these questions are not very useful, because the answers are so restricted. If you have a query about a problem, you will often find that it is answered in the example.

Have Fun

Five hours hard work programming may cause you to forget that the primary objective is to enjoy yourself. There will be plenty to do at DCU, so make the most of it.

Scenario

Imagine it is it is the start of the first day’s session. You are sitting at your assigned PC. Heart is pacing a little, and you miss the odd breath (the even ones seem a mite dodgy too). You are given the problem sheet. There are three problems in order of difficulty. You decide to start on the first.

So there you are knocking away at the problem. You write down some general ideas that come to mind, trying to understand the problem, and think of various ways that it can be tackled. A quarter of an hour passes. You decide it’s time to tap at the keyboard. Well, might as well get the file input part working. You write some code that reads in the input data from the file (Good job you practised those file handling commands). It seems to be coming along. You test your code on the sample data file that you are given. You spot a small error, fix it and now it’s working. It reads the input data correctly. That wasn’t too bad.

Now to get the program working. You work away, and it comes together. An hour gone. You try it with the test data, compare it with the sample solutions, and you see a few errors. A few more fixes and the program seems to work. Now you write the file output part. Finished and there’s three hours left. Just check that your program produces an output file that matches the sample solution file that you are given.

Good, better hurry for the second problem. It seems a bit harder, so do the file input, solve the problem, do the output, finished. An hour and a half left. Check the program with the test data, does it match the sample answers. No... few more changes to make. OK seems to work, one hour left. Make a bash at the third problem, Get the input part working, and create the output file (you get marks for that). Not enough time to finish the last problem. A supervisor announces that there’s quarter of an hour left. Better make sure that you save the correct version onto the hard disk. The first problem is called DAY1A.BAS (assuming the program was written in BASIC), and has to be saved on the root directory. It also has to be copied onto the floppy disks, one for yourself, and one for the organisers. The second problem should be called DAY1B.BAS, and the last one (surprise, surprise) is DAY1C.BAS. These should also be in the root directory and copied onto the two floppies. You hand up one floppy (with the three programs) to the organisers, and you go away before they switch off the machines at 5 o’clock.

Great that’s over.

Now however, the program is being marked. OK let’s see how it’s getting along. Well they’re using some of the test data that you were given, and you know that works, so you passed the first bit. Now they’re trying it with some more test data. It works for some of it, but it doesn’t work for the last test, and you realise that you forgot to consider one type of input that foxes your program. Oh well, not too bad, your mark is 65 and your in the top 30. There’s always tomorrow. Now let’s demolish the food and see if that party is any good.