DEV Community

R.Prabhakara Arjun
R.Prabhakara Arjun

Posted on

How to create a HackerRank Contest?

  • 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
  • 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
  • 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 in Langugaes
    • Paste the below code and click Generate Code stubs then you are ready to go.
EXAMPLE1 ✏️

function(boolean,isPower,integer n)
integer(n)
invoke(boolean,result,isPower,n)
print(boolean,result)

Enter fullscreen mode Exit fullscreen mode
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)

Enter fullscreen mode Exit fullscreen mode
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
└── ...
Enter fullscreen mode Exit fullscreen mode
  • 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 πŸ’‘


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

  • 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.