cpcpp - is an useful script which will enhance your productivity of solving Competitive Programming Problems by helping you to automate some common routines like building your code with some mostly used GCC flags, running your code on different tests without executing it many times, and providing nice visual colorings :3
Script only works for C/C++
-
Clone the repository:
% git clone https://github.com/reestear/cpcpp.git
-
Navigate to the project directory
% cd ./cpcpp
-
Copy script to your PATH directory
% sudo mv cpcpp.sh <PATH>/cpcpp
Where PATH directory on UNIX systems is by default any of following:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
-
Activate Script
% sudo chmod +x <PATH>/cpcpp
-
Look at the usage of script
% cpcpp
-
Navigate to the directory where your code is located and run:
% cpcpp <filename>
In this way, the script will build the program with default GCC Optimization flags with -std=c++20 and run the program immediately if compilation was succesful, otherwirse an error message will be displayed indicating an unsuccesful compilation.
The same behavior can be generated using
-r
and-b
flags, which will be discussed shortly later on:% cpcpp <filename> -b -r
-
Run existing executable without rebuilding the same source file
% cpcpp <filename> -r
If there exists an executable named
<filename>
, but without its.cpp
or.c
extension, then it will just run the existing program without compiling the source code.Otherwise, an error message will be displayed and program wouldn't be executed.
-
There exists similar option but only for building
% cpcpp <filename> -b
This way it will only compile the source code without executing the final output.
-
If you want to run the same code on multiple tests (Not those tests which will be run in the program itself)
% cpcpp <filename> --tests=<X>
or
% cpcpp <filename> -t <X>
Where,
X
stays for the number of tests which should be executed i.e how many times the program will be executed.Keep in mind that
--tests=
has a higher priority over-t
. Also, if no natural number representing number of tests is provided after-t
flag then an error message will be displayed. -
You can combine flags
% cpcpp <filename> -r -t 5
This will run your existing executable on 5 tests.
% cpcpp <filename> -b -r -t 5
This will build and run your code on 5 tests. (Essentially the same as
cpcpp <filename> -t 5
)