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 and their output. This helps candidates in debugging their code and understanding a 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 custom input to debug their code. In this case, they can themselves determine the expected output and use custom input to determine if their code is showing the same output as they determined.
The candidate's 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 INTEGER as the return type.
- Select INTEGER ARRAY from the function parameter type list and give the parameter a name n.
- Click the Generate Code button to generate the 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.