DWITE Online Computer Programming Contest

Quiz Time

December 2009
Problem 1

Building “quiz” applications is a popular assignment/project/whatever task for students learning programming. There are many that type up 500+ lines of code, but trust me – we can do that in much less.

The idea is that we will decouple data from code. The questions and answers themselves are not code – they are just data – and so they should live in a separate data file. As such, we only need enough actual programming to display just one question – any question read from a data file. To make things more interesting though, we’ll be reading the questions out of a data file in a “random” order.

The input file DATA1.txt will contain 5 sets of input. Each set starts with a question line no more than 255 characters long, followed by a “random” integer which specifies which output line the question should appear on. (Since we can’t mark against actual random results, we’ll tell you what “random” values to use.)

The output file OUT1.txt will contain 5 lines, which are the questions from the data file arranged in the specified order.

Sample Input:
question one
4
question two?
5
DWITE
2
What city is the capital of Canada?
3
meep.
1
Sample Output:
meep.
DWITE
What city is the capital of Canada?
question one
question two?