I have planned to use this generator system for all my future problems.
PRs are much appreciated!
This is the main script that does all the job:
- Prepares the inut/output folders. Creates folders
input
andoutput
if they don't exist. Then, empties these folders (in case there weren't empty). - Generates input files using the generator. Generates the test cases by running an instance of
InputGenerator
class intestcase_generator.py
, then writes the generated test cases into theinput
folder with the file name formatinput_[test_case_no].txt
. - Generates output files using
sol.cpp
. Compiles and runssol.cpp
for each input file created. Here, actually the C++ program (sol.cpp
) generates the output file. - Zips the generated files. Using
shutil
, zipsinput
andoutput
folders intotestcases.zip
.
You should write the whole solution code in sol.cpp
as if you're trying to solve the problem.
This file is outside the flow. However, implementing the solution in Python is also considered nice practice :)
This file contains common utility functions such as random number generators, tree generators etc. You may use this file just to have some idea.
The actual stuff is done here. There are several classes inside this file:
class Input
: Defines and wraps the parameters forming the input of a single test case file. Since it varies from problem to problem, you should rewrite it for each problem.class InputGenerator
: Implement all your generators with their particular generation logics inside this class.main.py
calls itsgenerate
method to generate the inputs.