Adding support for more than just CHelper
See original GitHub issueThis issue is open to discussion, but is primarily meant to keep track of progress on this idea, and to serve as some sort of documentation.
CHelper Companion was originally designed to solely support CHelper, but it would be cool if it would be able to send tasks to other tools aswell. Therefore, I have been thinking about sending the task information as a JSON-encoded string. This makes it easier for other (private) tools to work with the extension, as long as it can parse JSON input from an HTTP request.
The format
Here’s an example of possible input:
{
"name": "The A + B problem",
"group": "Educational Codeforces Round 42 (Rated for Div. 2)",
"url": "http://codeforces.com/problemset/problem/962/G",
"memoryLimit": 256,
"timeLimit": 2000,
"testType": "single",
"input": {
"type": "stdin"
},
"output": {
"type": "stdout"
},
"languages": {
"java": {
"mainClass": "Main",
"taskClass": "TheABProblem"
}
},
"tests": [{
"input": "1 2\n",
"output": "3\n"
}, {
"input": "5 5\n",
"output": "10\n"
}]
}
It’s not required for a tool to parse all these options, since some of them are tool/language-specific. However, it is required for all extensions/tools that send data via this format to fill all required options.
Explanation
- name: The full name of the problem. Can be used for display purposes.
- group: Used to group problems together, which can be useful for archiving purposes.
- url: A link to the problem on the judge’s website.
- memoryLimit: The memory limit in MB.
- timeLimit: The time limit in ms.
- testType: The type of the tests. Supports three options: “single”, “multiNumber” and “multiEOF”. Explanation of these three can be found on the JHelper wiki. This is currently CHelper and JHelper specific.
- input: An object which is used to configure how to receive input. Supported types:
- stdin: Receive input via stdin. No additional options required.
- file: Receive input via a file. The file name has to be given via the fileName option.
- regex: Receive input via a file. The file to use is selected by taking the most recently modified that matches the given regex. The regex pattern to use has to be given via the pattern option.
- output: An object which is used to configure how to send output. Supported types:
- stdout: Send output to stdout. No additional options required.
- file: Send output to a file. The file name has to be given via the fileName option.
- languages: An object with language specific settings. At the moment this only contains Java settings, but since I don’t think putting language specific settings as top-level options is a good idea, I decided to put them in an object. This also allows for other languages to have custom configuration added later on. Required keys:
- java: An object with Java specific settings. Required options:
- mainClass: The name of the outer class containing the solution.
- taskClass: The classname-friendly version of the problem’s full name. Cannot be the same as mainClass. Can also be useful for non-Java tools because a classname-friendly string is also a filename-friendly string.
- java: An object with Java specific settings. Required options:
- tests: An array of objects containing testcase-data. The JSON objects in the array all have two keys: input and output. Both the input and the output need to end with a newline character.
Pro’s
- Being able to support more than just CHelper, even private tools as long as they can parse JSON input received via HTTP.
- At the moment the extension would break if Egor changes the Kattis parser. A JSON parser would resolve this issue.
Cons
- The extension would have to be renamed to something more general, since CHelper Companion implies it’s only compatible with CHelper.
Tasks
- Convert the problem and contest parsers that still rely on CHelper to a JavaScript implementation
- Make all parsers parse the time limit of a problem
- Add a JSON parser to CHelper
- Add a JSON parser to JHelper
- Add the functionality to Hightail to accept JSON input via HTTP and parse it
- Make it possible to send the JSON data to multiple tools
- Make it possible to send the JSON data to a custom port on localhost to support private tools
- Create better documentation so it’s easy for new tools to support the format
- Create an example to show how to support receiving the JSON data in other (private) tools
- Rename CHelper Companion to something more general (final step)
All changes on the extension relevant to this issue are done in the feature/universal branch.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:13 (9 by maintainers)
Top GitHub Comments
From what I can see, JHelper uses a packaged version of CHelper, so I’m patiently waiting for Egor to merge my PR in his repository before I make a PR in yours to update the packaged CHelper library (so the CHelper library in JHelper is up-to-date with the latest version of CHelper).
All tasks are completed, Competitive Companion now has support for CHelper, JHelper, Hightail and Mind Sport.