This discussion tells you about the creation of mapping script for test data. For example-Today, CodeChef works as a black box. Which means that when you submit a solution, the verdict that you get is either an Accepted or not-accepted (WA, RTE, TLE). You do not get to see where your code has failed, i.e, on which test case! The philosophy behind this has been to not give away the wrong test case easily. To know where one has gone wrong, one should try and arrive at it by looking at the editorials of the problems and other people’s solutions.
However, going ahead, as we intend to bring programming to the kids, we realize that we may need to show them the test data where their code has gone wrong. And, this cannot be achieved without making changes to all the existing problems that we have in our database. We will need to change the test data of every single problem in our database to introduce a mapping between the input and output test case, which does not exist today. This is essential for figuring out for which input file the user’s solution has gone wrong.
This task will want you to write a script to do so for a bunch of problems.
Problem Description: Let us go through a sample problem:
Problem statement: *At the beginning number, n, is given. It corresponds to the number of tests. In the following n lines, numbers a and b will appear. Your task is to add numbers, a and b and print the result to stdout.
input:
3
2
3
3
4
5
8
output:
5
7
13*
For the above problem, the judge at the backend will have a set of input files and a set of output files. However there is no mapping that exists today between the input and these input files and the output files. The way the judge works is take the user’s solution and run it on the input file to generate an output which is then matched in entirety with the expected output. If it matches the solution is Accepted or else it is not. If the generated output does not match the expected output, there is no way to tell for which input it does ot match.
We have to create an Input Meta Data File which will tell the judge where each input case starts and ends. In this file, the ith line represents the ith test case which consists of two numbers
- The line number in the input file from where the ith input case starts
- The line number in the input file where the ith input case ends
For the input in the above problem, the input meta file that you will need to generate will look like this:
2 3
4 5
6 7
Similarly, we have to create an Output Meta Data File which will tell the judge where each output case starts and ends. In this file, the ith line represents the ith test case which consists of two numbers
The line number in the output file from where the ith output case starts
The line number in the output file where the ith output case ends.
For the output in the above problem, the output meta file that you will need to generate will look like this:
1 1
2 2
3 3
Not, let us assume that the user’s program’s output is (which is wrong for the second input case):
5
9
13
Normally the judge output will be a wrong answer. However, if we upload the above two meta files, the judge can be made to show the input case for which the solution went wrong. (This is just for your understanding and your task has nothing to do with this).
3
4
7
9
Task Description: Your task is to write 2 scripts for each problem given to you, in any one of the languages mentioned below. One for generating the input meta file and the other for generating the output meta file. You have to find out the input and output pattern by reading the problem statement. You may also refer the correct submissions for the problems to understand how to read the input from the console.
Your program should read the input file from STDIN (console) and write the corresponding meta file to STDOUT (console).
Your input meta file generation script should be named in the format PROBLEM-CODE + ‘’-in”’ + extension (like c or java). For example if your are writing your script in c and the problem is XORSUB, your meta-input generator script file will be XORSUB-in.c
Your output meta file generation script should be named in the format PROBLEM-CODE + ‘’-out’’ + extension (like c or java). For example if your are writing your script in c and the problem is XORSUB, your meta-output generator script file will be XORSUB-out.c
Languages allowed:
- C/C++
- JAVA
- Python
- PHP
Reference Material:
Sample Input Meta File Generation Script for the above problem in C: https://codechef_shared.s3.amazonaws.com/download/sample-in.c
Sample Output Meta File Generation Script for the above problem in C:
https://codechef_shared.s3.amazonaws.com/download/sample-out.c