How to Add New QuestionsBy: Homecox. 08/15/2013This article discusses how to add new OJ questions. A new OJ question submission should include these information:
Add test cases One can add test cases, this is simple. Just include small and large test cases in plain text file. Each test case on one line. Specify your notations. Please do make good test cases. Add entire test files Another option is to add entire test files. This involves more work. It can take 30 to 60 minutes for one question (including C++ and Java) using the Homecox OJ read/dump/equal API: OJ class in C++ (OJ.cpp, API) and Java (OJ.java, Test.java, API). Note OJ.java and OJ.cpp are released under the 3-clause BSD license. This is much faster than when I worked on the first question, which took me 5 hours, and most time were spent on writing input/output/compare functions for different data types. An example using the "climbing stairs" question (for its simplicity):
Explanation For both Test.cpp and Test.java, the top part is "class Solution", this is the same as user submitted code. You can use either correct algorithm or a place holder, but correct function signature is required. The second part is "class OJ". This includes read/dump/equal functions needed for the input/output types of this question. It could include the entire OJ class. However, to make it succinct, just copy and paste relevant functions here. The last part is "class Test". Place test cases in constructor Test(). In function test(), change input/output data types. Finally if provide the correct algorithm, put it in the "Correct algorithm for the question" section. The relevant sections that need change are labeled 1) to 4) in the code. Test.cpp and Test.java should compile and can execute to generate identical output in the desired format. For example, both here will generate this output: Note there are 2 ways of providing output for test cases:
|