You can create coding questions to test the most relevant skills of the candidates. By creating questions that require candidates to write real working code and not just pseudocode, you can ensure that candidates have the required skills for the role. This article will walk you through the steps in creating a coding question.
Steps to Create a Coding Question
- Click on the Library tab on the Home page, and then click on the Create Question button.
HackerRank Library Page
- In the Select Question Type dialog box, under the Programming category, click on the Coding option.
Selecting a 'Coding' type Question
- On the Problem Statement tab, specify the following:
A. Problem Name
- The problem name should be short and should not give any hints to solve the problem.
- (Optional) Select the Tags from the drop-down list or add your own custom tag.
- Tags are words or phrases that help with the searchability and organization of your questions. You can add the existing tags or create new tags. Set the difficulty level for your question by associating the tags as Easy, Medium, or Hard. Alternatively, associate custom tags to identify your question by its complexity or its levels.
- When you view your questions in the Library, the associated tags will be indicated for every question. You can use these tags to generate candidate reports and performance graphs.
- Refer, Associating the Tags for Questions for more information.
C. Problem Description
- A good problem statement should comprise a clear and detailed problem description, at least one sample test case with an explanation, and constraints of the problem.
- Click on the Templates option to use the predefined HackerRank's Coding Question template to define your problem clearly.
- Refer to the Defining the Problem Statement: Coding and Database Engineer Questions topic for more information.
D. Interviewer Guidelines
- Interviewer guidelines are for later reference. You can include a rubric about scoring the questions or write solutions to the problems in this section. These can be used by your team while evaluating the test. This step is optional.
You can also attach a relevant reference file in these sections. Refer to the How to Attach a File to a Problem Statement topic for more information.
- Enter the amount of time, you expect candidates to spend on this question.
- Click on the Save & Proceed button.
Note: Interviewer Guidelines are only visible to you and your team members and in the candidate report.
On the Languages tab, follow the below instructions:
- Click on the Clear all option so that the candidates can select the check-boxes to solve the problem in any selected language.
Allowed Programming Languages
- In the Code Stub section, specify the function name, return type, and it is optional to add function parameters and then click on Generate Code to generate the code stub. Refer to the article on Code Stubs for more information.
Generating Code Stubs
- A dialog box is displayed that lists the languages for which auto-generated code stub is not supported.
Programming Languages for which Code Stubs not Supported
Note: This dialog box is only displayed if your allowed languages include one or more unsupported language for automatically generated code stub.
- In the displayed dialog box, you can either choose to deselect the unsupported languages for automatically generated code stub or retain these languages and then click on the Yes, Generate Code button.
- If you deselect the languages, then those languages are not allowed for answering this question. If you keep these languages, you have to manually select the language in the Default Stub section and type the code stub.
- In the Default Stub section, you can select the languages from the drop-down menu to see the generated code stub.
- Click on the Save & Proceed button.
In the Test Cases tab, perform one of the following operations:
- If you want to add test cases one by one, click on the Add test case button. In the Add Test Case dialog box:
- Specify the Name of the test case.
- Select the Difficulty level of the particular test case.
- Enter a Score for this test case. If the code passes this particular test case, this score is assigned. The sum of scores of all test cases is the total score assigned to a coding question.
- Specify the Input and Expected Output values for the test case.
- Optional: Select the Mark as sample test case check box if you want this case to be a sample test case.
- Click on the Save button.
Adding Test Cases
Note: You must assign a score to a particular test case, depending on the difficulty level of the test case.
- Repeat the steps as illustrated above to add more test cases.
Defining Test Cases to Validate the Code
- Refer to the Defining Test Cases for Coding Questions article for more information on test cases.
- Click on the Upload as .zip button to upload multiple test cases.
- In the Upload Test Cases dialog box, click on the Choose File button to upload a zip file that contains test cases from your local system.
Click on the Upload button to upload the zip file.
Click on the Upload as .zip button.
Note: This method is preferred when either the size of input and output is large, or the number of test cases is large. The input files in the zip are named input000.txt, input001.txt, and so on. The output files are named output000.txt, output001.txt, and so on.
- Click on the Advanced Settings option to add additional data source files or to enable network access for the questions. You can enable the network access by ticking the Enable network access for the question checkbox.
- Click on the Upload Solution button to add a solution for this problem to help candidates debug and see the expected output for their custom input.
- Click on the Save Question button to save the question and exit.
- Alternatively, click on the Save & Add another button to save this question and proceed to create another one.
Advanced Settings, Upload Solution and Save Question
- The Questions you create are stored in the HackerRank Library under the “My Company questions” section. The Question type and the associated tags are indicated below every Question title as shown below.
Coding Question in the Library
In the Quality Review section, you can review and add test cases or sample test cases, modify the code stubs and add more tags.
- Click on the Try question button
- In the opened code editor, scroll down and select the check-box Test against custom input to add your custom input.
- Click on the Run Code button to check the status of whether the code is passed or failed the compilation.
Run Code with Custom Inputs
- Click on the My Company Questions tab to view your company questions.