You might also like to see the tips on solving problems.
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.
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.
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.
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.
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.