A command-line tool to generate Online-Judge problem.
- Render problem descriptions in Markdown to HTML
- Check problem descriptions and data, including missing fields, UTF-8 encoding, end-of-line CRLF/LF
- Packing problem data in freeproblemset(hustoj) format
- Mechanism for generating input and output test data
- Easy to define adapters for other online-judge platform
Have fun! If you have any suggestions or find any bugs, please tell me.
pip install generator-oj-problem
# or use pipx for a standalone python environment
pip install pipx
pipx ensurepath
pipx install generator-oj-problem
gop --help
# Initialize your problem
gop init
# Modify the files to write problem
ls .
# Generate 2 sample data from id 1
gop gen -s 1 -c 2 --sample
# Generate 5 test data from id 2
gop gen -s 2 -c 5
# Trim sample and test data
gop trim
# Check validaty
gop check
# Pack your problem in FreeProblemSet format
gop -a fps pack
If you meet some encoding errors, ensure your Python interpreter runs in UTF-8 mode, e.g. adding PYTHONUTF8=1 to your environment variables.
Here is a demo problem A + B Problem. Details about
problem.yml
andgenerator.py
are given at the comments of the demo files.The file with extension
.md
means it supports plain CommonMark by built-in render. Attention: No LaTeX and embeded image supports.
problem.yml
Problem metadata and configurationdescription.md
Descriptioninput.md
Description of inputoutput.md
Description of outputhint.md
Hintsolution.txt
Solution source codegenerator.py
Generator for input or output data.samples/
Sample datasamples/0.in
Input of samplesamples/0.out
Output of sample
tests/
Test data (same form tosamples/
)