- Hello everyone this is R.Prabhakara Arjun,πΊ
- I faced a hard time creating a HackerRank contest without proper guidance and clear documentation.
- If youβre a fellow tech enthusiast facing the same challenge, youβre not alone! To help others avoid the confusion I went through, Iβve documented my full experience and provided a step-by-step guide to setting up a contest.
- The complete markdown is there in my
git
: HACKER-RANK-CONTESTS
I hope this helps all the aspiring contest creators out there. Happy coding!
HACKERRANK-CONTESTSπ
ABOUT π
- The below documentation will guide you how to create a coding contest
- what's given the below is a part of
DSL
(Domain Specific Language) which is like a pesudo code that will create code blocks of your defenition.-
DSL
helps you create code stubs like main function and solution function - You can decide the input types and parameters.
-
STEPS TO CREATE A CONTEST π οΈ
- STEP-1: Siginin and login into hackerrank got to Dashboard
-
STEP-2: Click the top right corner which contains the logo,you will get to see the
profile->dark mode->leaderboard->settings->bookmarks->network_>submission_>administration->logout
- Choose the
administration
- Choose the
- STEP-3: Click create contest button and exploration is up to you.
TIPS π‘
-
Moderators
are the one who is like admin in whatsapp group,they have acess to your contest and they can manage them- If you are going to make an official contest with large number of people do it as a team,do it with moderators.
-
Challenges
are the place where you create your own question or (in-built)make use of already made question form hacerrank.
STEPS TO CREATE A CHALLENGE π§ͺ
- You will come across the word challenges these are custom made problems.
- You can build your own question
- Go to
administration
page click here - Choose
Manage chalanges
-
STEP-1: Click
Create challenge
- STEP-2: You can always change this create page later. so make it as a simple dummy page(fill rubbish),just give a proper Challenge Name as of now and minimal description u can change it later.
-
STEP-3: In
details
you can change the entire description,you can modify problem statement,etc.- Note everything is a
MarkDown
so you can style it,it is saved as .md - You can preview the content
- Note everything is a
-
STEP-4: here comes the fun part
- Go to
Code stubs
,this is the place where you will create stub which will generate template code in all languages you have selelcted inLangugaes
- Paste the below code and click
Generate Code stubs
then you are ready to go.
- Go to
EXAMPLE1 βοΈ
function(boolean,isPower,integer n)
integer(n)
invoke(boolean,result,isPower,n)
print(boolean,result)
EXAMPLE2 βοΈ
function(2d_integer_array, findMe2, integer l, integer m, integer n, integer target, integer_array arr)
integer(l) integer(m) integer(n) integer(target)
Array(integer, arr, l, single)
invoke(2d_integer_array, result, findMe2, l, m, n, target, arr)
print(2d_integer_array, result)
How it works? βοΈ
-
function
creates a function with syntax given below - inputs are given in the next few lines with synatx given below
-
invoke
calls it -
print
makes the user get to see the output.
TEST CASES π§ͺ
-
NOTE: The
input
is given in the format how you gdefined the code in your stubs(DSL) -
output
is just the answer for the input what you gave. - You can give it as sample and explain it. This is visible once you click the pencil option
- Also You can change strength for each test case.
- To create a large number of test cases you can write a custom script that will define files as
testcases.zip
βββ input00.txt
βββ output00.txt
βββ input01.txt
βββ output01.txt
βββ ...
- You can code solution for you code and create a script(py code,java code) to create a new file under a empty folder with proper matching name.
- Then you can zip it
- Upload it
TIPS π‘
- How Do I Upload All Test Cases at Once?
- For creating arrays input give spacing properly.
- For boolean output give
1
or0
.
DSL π§
Welcome to HackerRank DSL (Domain Specific Language) Documentation! You can use our the DSL to generate code stubs that read test case data from standard input in hackerrank challenges.
- Datatypes Supported
- Reading Variables
- Writing Loops
- Reading 1-D Array
- Reading 2-D Array
- Putting Comments
- Generating Functions
- Invoke a Function
- Print a Variable
- DSL In Action
- Bug Report or Need help?
Datatypes Supported
- Integer:
integer
- Float:
float
- String:
string
- Boolean:
boolean
- Long Integer:
long_integer
- Character:
character
Reading variables
Syntax | Example |
---|---|
Datatype(variable_name) |
integer(a) |
At most 4 variables per line is supported | integer(n) integer(k) |
Writing Loops
You can use loops to read multiple test cases.
Syntax | Example |
---|---|
loop(variable_name) {code} endloop
|
loop(t) integer(n) endloop |
Reading 1-D Array
Syntax | Example |
---|---|
Array(Datatype,name,size,single) |
Array(integer,a,n,single) |
Array(Datatype,name,size,multi) |
Array(float,b,m,multi) |
Note: Type is single
if the array elements are on the same line. Otherwise, it should be multi
.
Warning: Don't leave any extra space.
Reading 2-D Array
Syntax | Example |
---|---|
2DArray(Datatype,name,size1,size2) |
2DArray(integer,a,n,m) |
Putting Comments
Syntax |
---|
#Your own comment |
A special comment is #StartCode
, this will generate the text "your code goes here" as a comment.
Generating Functions
Syntax | Example |
---|---|
Function(return_type, function_name, param_type1 name1, param_type2 name2, β¦) |
function(integer_array, solve, integer x, integer_array board) |
-
Return type/Param type supported:
- integer
- long_integer
- string
- integer_array/long_integer_array/string_array
- 2d_integer_array/2d_long_integer_array/2d_string_array (param only)
- void (return type only)
Invoke a Function
Syntax | Example |
---|---|
INVOKE(return_type, variable_name,function_name, param1, param2β¦) |
INVOKE(integer_array, result, solve, n, board[n]) |
- If the invoked function is void, return_type and variable_name should be βvoidβ.
- If the param is a 1-d array, format is param[size]
Print a variable
Syntax | Example |
---|---|
PRINT(data_type, variable_name) |
PRINT(integer, result) |
PRINT(data_type, separator) |
PRINT(integer_array, result, +) PRINT(integer_array, result, NEWLINE) PRINT(integer_array, result, COMMA) |
The third parameter is optional. The default separator is space. The separator can be NEWLINE, SPACE, COMMA or any character.
Data_type supported are single integer/long_integer/string and 1-d integer/string/long_integer array.
DSL In Action
Challege | DSL |
---|---|
https://www.hackerrank.com/challenges/mark-and-toys |
integer(n) integer(k) Array(integer,a,n,single)
|
https://www.hackerrank.com/challenges/two-arrays |
integer(t) loop(t) integer(n) integer(k) Array(integer,a,n,single) endloop
|
https://www.hackerrank.com/challenges/breaking-best-and-worst-records |
FUNCTION(INTEGER_ARRAY, getRecord, INTEGER_ARRAY s) Integer(n) Array(integer,s,n,single) INVOKE(INTEGER_ARRAY, result, getRecord, s[n]) PRINT(INTEGER_ARRAY, result)
|
https://www.hackerrank.com/challenges/cavity-map |
integer(n) 2DArray(character,grid,n,n+1)
|
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.