Candidates debug their code by using custom input when some of the hidden test cases do not pass. If the question setter has uploaded a solution while creating the question then the expected output is readily available to the candidates. In this case, candidates can add their own input and run code to compare the expected output against their output. This helps candidates in debugging their code and understanding the reason why their test cases are failing.
However, even if the question setter has not uploaded a solution while creating the question, candidates can use the custom input to debug their code. In this case, they can themselves determine the expected output and use the custom input to determine if their code is showing the same output as they determined.
Note: If you're a Candidate looking for information about debugging your code using custom input, see the Debug using custom input topic.
Custom Input Format - Sample
The candidates have to enter the input in a particular format to test their code. The following example explains the custom input format in detail:
Problem statement: For the given array of integers, write a function ArraySum to return the sum of its elements.
To generate the code stub automatically while creating a question, describe the function signature in the code stub form.
- Enter the function name, ArraySum.
- Select the INTEGER as the return type.
- Select the INTEGER ARRAY from the function parameter type list and give the parameter a name n.
- Click on the Generate Code button to generate the code stub.
Generating a code stub
While creating test cases for this problem, be aware of the format the stub code is expecting. For a test input array of length Y, the test case input contains (Y + 1) lines. Here, the first line specifies the length of the array and each following line specifies the element of the array on a separate line.
For example, for the input array [10, 20, 30] and integer n= 123, the test case's input that a candidate requires to enter is:
The test case's output would be the sum of the elements: 60.
Allowing code testing with custom input