This command line utility is meant to make it easy to download and run programs for use in CodeForces contests. It will automatically download contest problems, including sample test cases, and will compile and run code against these test cases. A fork of CodeforcesRunner.
Also includes starter files. Meant to be a "batteries included" way of doing Codeforces contests.
The package is available on PyPI. It can be installed with the following command:
pip install ecfr
This command line utility has four commands:
dc Download contest or individual problems
init Copy example files into the current working directory.
r Run code against contest problems.
sp Create an empty solution file from a starter file in the source files folder.
Each one has different arguments that can be viewed by looking at the help messages.
We will use Codeforces Contest 198
as a running example. This will demonstrate the workflow of using ecfr
as a
command line utility.
The first thing we must do is create an environment config file and provide
starter files for languages we would like to use. Fortunately, ecfr
includes
a sample config and starter files with reasonable defaults. To use them, we must
simply navigate to the directory we would like to do the contest in and run
$ ecfr init
Now that we have starter files and a basic config, we need to download the contest. We can download contest 198 using the following command.
$ ecfr dc 198
To download just problem A, we can add the -p A
arguments. This creates a
.xml
for each problem downloaded, including the sample test cases.
You may add additional test cases by following the format of the .xml
files.
By default, these are put into the contest_files
directory.
Now that we have our problem files downloaded, we can start coding. To do this, we need to copy a starter file for our desired language and give it a descriptive name, according to the problem we will be solving. Let's say we wish to do problem A in the contest we downloaded in Python. We can create our file with the following command:
$ ecfr sp A py
This will create a file called A.py
in the source_files
directory (the location can
be set in the config). Here, py
is the file extension ecfr
will look for when making
a copy of the starter file. The directory for starter files can be set in the config file.
Once we have our starter file and finish coding, we want to run the tests that we downloaded. To do this, we simply run the following command:
$ ecfr r A
With this command, ecfr
will look in the source_files
directory for files matching problem
A. When a file is found, it will automatically compile and run it against all test cases in
the A.xml
file.
Once all test cases pass, we wish to submit our source file. This is as easy as selecting
A.py
and uploading the file on the contest submission page. Make sure to select the
appropriate programming language. If you are using Python 3, be sure and submit to PyPy3,
as this generally runs much faster.
The file conf.json
contains the used compile and execute commands. More commands
can be added for different languages. In addition, names of directories for source files,
contest files, and executables can be changed.
This tool is only verified on Linux and is still considered in beta. Once more testing has been done and more test cases have been added, we will proceed with a full release.
Thanks to sayuan and all of the contributors to the original CodeforcesRunner project. Additional thanks to dhashe for help testing this project.