Package: ecfr
ecfr: Eliot's CodeForces RunnerThis 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 ofCodeforcesRunner.Also includes starter files. Meant to be a "batteries included"
way of doing Codeforces contests.InstallationThe package is available onPyPI. It can
be installed with the following command:pipinstallecfrCommandsThis command line utility has four commands:dcDownloadcontestorindividualproblems
initCopyexamplefilesintothecurrentworkingdirectory.
rRuncodeagainstcontestproblems.
spCreateanemptysolutionfilefromastarterfileinthesourcefilesfolder.Each one has different arguments that can be viewed by looking at the help messages.UsageWe will useCodeforces Contest 198as a running example. This will demonstrate the workflow of usingecfras a
command line utility.InitializationThe first thing we must do is create an environment config file and provide
starter files for languages we would like to use. Fortunately,ecfrincludes
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$ecfrinitDownload Sample TestsNow that we have starter files and a basic config, we need to download the contest.
We can download contest 198 using the following command.$ecfrdc198To download just problem A, we can add the-p Aarguments. This creates a.xmlfor each problem downloaded, including the sample test cases.
You may add additional test cases by following the format of the.xmlfiles.
By default, these are put into thecontest_filesdirectory.Starting a ProblemNow 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:$ecfrspApyThis will create a file calledA.pyin thesource_filesdirectory (the location can
be set in the config). Here,pyis the file extensionecfrwill look for when making
a copy of the starter file. The directory for starter files can be set in the config file.Running the TestsOnce 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:$ecfrrAWith this command,ecfrwill look in thesource_filesdirectory for files matching problem
A. When a file is found, it will automatically compile and run it against all test cases in
theA.xmlfile.SubmittingOnce all test cases pass, we wish to submit our source file. This is as easy as selectingA.pyand 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.ConfigurationsThe fileconf.jsoncontains 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.AboutThis 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.AcknowledgementsThanks tosayuanand all of the contributors to the originalCodeforcesRunnerproject.
Additional thanks todhashefor help testing this project.