A code snippet is boilerplate code which is code that can be used without changing it.
When a candidate writes code, it is evaluated using input (STDIN) and output (STDOUT).
- STDIN: The default source of providing input to any computer program.
- STDOUT: The default channel where the output of the program is written.
What is code-snippet generation?
You can generate code snippets automatically. This will allow the candidate to focus on writing the logic required for the program to run.
A candidate must write the code to add N numbers (1, 2, 3…N). The code will be as follows:
Note: The code has been written in different colors only for clarity. In this code the colors mean the following: blue = input, orange = logic, green = output.
By using the code-snippet generation feature, you can generate the input and output automatically. This is known as ‘skeleton code’. The skeleton code will be visible to the candidate who can focus on writing the logic that will ensure that the code runs successfully.
For more information, see Generating code snippets.
Advantages and benefits
This feature has many advantages and benefits for recruiters and candidates.
The earlier code snippet feature required recruiters to write code snippets for different languages from scratch. The new feature saves a lot of time because now the recruiter must only enter the required values and generate the code. The same code is generated automatically for all the different programming languages which can be viewed as easily as selecting the required language from a drop-down list.
Candidates who take online coding tests are usually not familiar with the online coding process. There may not be enough time for a candidate to understand HackerEarth’s evaluation process—specifically how the input (STDIN) and output (STDOUT) should be written to ensure that the evaluation process runs correctly.
If the skeleton code is already available, then the candidate can do the following:
- Focus on writing the logic that is required to solve the problem
- Not spend time figuring out the input (STDIN) and output (STDOUT) that needs to be used