Competitive Programming Grader For All Programmers

Ryota Bannai
2 min readDec 31, 2021

Do you guys do competitive programming? I am a newcomer for the first time in a few months in 2021.

As anyone who participates in the contest knows, a penalty will be imposed if the submitted answer is incorrect or a compile error occurs, so at least check the operation with the sample posted before submitting and there is no problem.

Also, if the answer is incorrect after submission, I think that I will reread the question sentence or try various input values ​​to see what pattern was missed.

In this latter case, it is wasteful to manually pass many test cases to the standard input each time and check the standard output side by side with the answer, or to know which case was a pass and which was a failure. Those lead to a lot of time loss.

Therefore, it would be nice to have a tool that manages test cases in files and executes all test cases automatically, so I created a command line tool called Competitive Programming Grader.

The usage is as described on the Github page, but I would like to introduce some features roughly.

There are two main types.

The first is a command to create a test case file.

cpg make -p [filename]

[input]

is displayed and the input is passed as the standard input for the answer.

[output]

is displayed and the content entered after this will be compared with the standard output of the answer.

This will automatically create folders and files.

The second is a command to run test cases.

cpg run -p [filename]

If the test fails, the expected value, output value, and the difference are displayed.

In this way, you can store test cases and execute them all automatically for the answer each time you make a correction.

It is currently available in MacOS and Linux and can be used in basically any language. If you find a bug or have a feature you need, please let me know in the Issues on the Github page above.

--

--

Ryota Bannai

I’m a learner of English as a second language, who’s obsessed with informative articles. I always like to learn new things. https://medium.com/ryota-bannai