Skip to content

geekyquentin/CF_test-case-parser_and_runner

Repository files navigation

Codeforces test cases parser and runner


Requirements

VSCode

Install VSCode

CMake

Install Chocolatey

Install CMake

Add path to Environment Variables

  • Right-click on This PC, go to Properties > Advanced system settings > Environment Variables
  • Click on the Path column in System variables and click Edit
  • Click New, paste C:\Program Files\CMake\bin, and click OK
  • Finally, close and reopen VSCode

Compiler: MinGW

In VSCode, go to File > Preferences > Settings

Search for C_Cpp › Default: Compiler Path and set it to C:/MinGW/bin/g++.exe


Overview

This repository contains the following files:

.clang-format: C++ code formatter that provides an option that lets the user define their custom code style options

CMakeLists.txt: directives and instructions describing the project's source files and targets.

fetch_cases.py: takes contest number and problem letter as input to access the specific problem with the URL (for example, https://codeforces.com/problemset/problem/1681/A) to parse all the test cases with its inputs and outputs into their respective text files

run.py: executes the code with the input generated by fetch_cases.py for all test cases

remove_exe.py: removes the executable of the program from CMakeLists.txt

make.bat: contains lines with commands executing in sequence. Performs multiple tasks as per the user's request, all of which are discussed in the next section


How to use

Clone this repository and open it in VSCode. To clone, run

git clone https://github.com/geekyquentin/cf_test-case-parser_and_runner

CMakeLists.txt might be having some executables added, and it throws errors when it doesn't find its corresponding source files. To remove the added executables from the list, run

./make.bat rex

Open a problem in the codeforces site. From its URL, get the contest number and the problem letter (for example, in https://codeforces.com/problemset/problem/1681/A, contest_number is 1681 and problem_letter is A).

Get test cases

To get the input and output for all test cases, run

./make.bat contest_number problem_letter gtc

Function: fetch_cases.py accesses the page and parses the test cases. make.bat creates problem_letter.cpp in the directory contest_number, adds an executable of this program to CMakeLists.txt, and opens it in VSCode.

Run the program

To run the program on every test case, run

./make.bat contest_number problem_letter debug

Function: make.bat generates the CMake build directory if it doesn't exist and builds all the executables that are added to the CMakeLists.txt. run.py runs the executable in CMake build directory for all test cases and writes the output to code_output.txt.

To compare the outputs, use run instead of debug

./make.bat contest_number problem_letter run

Add to TODO list

To add a problem to the TODO list, run

./make.bat contest_number problem_letter todo

Clean files

To perform a clean-up, run

./make.bat clean

Function: Deletes input and output files generated while parsing test cases and removes the CMake build directory


Other points to note

If the problem doesn't ask for the number of test cases as an input, edit the main() function accordingly

To disable GitHub Copilot for the .cpp files, add "github.copilot.enable": { "cpp": false, } to .vscode/settings.json

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published