Skip to content

Instantly share code, notes, and snippets.

@omerjerk
Last active February 10, 2017 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omerjerk/0c737b46831d226105e5c1ae7d422252 to your computer and use it in GitHub Desktop.
Save omerjerk/0c737b46831d226105e5c1ae7d422252 to your computer and use it in GitHub Desktop.

Coding Blocks Judge API

judge.cb.lk/api/submission

Description: Judge a submission

Request type: POST

Form data:

Keys Description
lang Language code of the source code to compile
maxruntime (optional) Maximum runtime in seconds for the solution to be run. Default is 5s.
source Source code in the base64 encoded format
input Input testcases in the form of a JSON Array of String, each being encoded in base64 format
expected_output Expected output in the form of a JSON Array of String, each being encoded in base64 format
get_output true, if output of the program should be present in the response, else false

Example form data:

{
    lang: "py2",
    source: "cHJpbnRmKCJIZWxsbyBXb3JsZCEiKQ==",
    test_count: 2,
    input: ["MSAyIDM=", "MyAyIDE="],
    expected_output: ["Ng==", "Ng=="],
    get_output: true,
    maxruntime: 5
}

Language Codes

Langauage Code
C c
C++ cpp
Java java
Python py2

##Response Types

Successful compilation and run with get_output being true

{
    "result":"success",
    "data":
        {
            "testcases":
                [   
                    {
                        "result":"correct",
                        "output":"Mw=="
                    }
                ]
        }
}

Successful compilation and run with get_output being false

{
    "result":"success",
    "data":
        {
            "testcases":
                [
                    {
                        "result":"correct"
                    }
                ]
        }
}

Note: When get_output is false, expected_output should never be null.

Compilation error

{
    "result":"compile_error",
    "error":"Q29tcGlsaW5nIGZhaWxlZCB3aXRoIGV4aXRjb2RlIDEsIGNvbXBpbGVyIG91dHB1dDoKcHJvZy5jOiBJbiBmdW5jdGlvbiAnbWFpbic6CnByb2cuYzo0OjE6IGVycm9yOiBleHBlY3RlZCAnOycgYmVmb3JlICd9JyB0b2tlbgogfQogXgo="
}

Run error

result will be success as the program compiled successfully. The result of each testcase will contain value run-error.

{
    "result":"success",
    "data":
        {
            "testcases":
                [
                    {
                        "result":"run-error"
                        ,"output":"SGVsbG8gV29ybGQh"
                    }
                ]
         }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment