Skip to content

Hegdahl/competitive-programming-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Competitive Programming Tools

My tools for programming competitions.

My data structures and algorithms have a new home: https://github.com/Hegdahl/competitive-programming-lib

> cpt --help
Usage: cpt [OPTIONS] COMMAND [ARGS]...

  Entry point for all cpt commands.

  Run `cpt COMMAND --help` for more info about the command.

Options:
  --help  Show this message and exit.

Commands:
  expand  Replace cpt includes with source code (for submission to online...
  flush   Clears temporary data stored by competitive programming tools.
  listen  Listen for information about problems from the "Competitive...
  run     Executes a program from source.
  stress  Run `source` repeatedly with input from generated by the...
  submit  Figure out where to submit a `source`, then submit it and show...

Example usage

example-usage

Platform support

No.

I only tested this on my own computer running linux.

Installation

  • Install python3, pip, and g++.

  • Clone this repository

  • cd into it

  • run this (maybe pip3 instead of pip depending on platform)

> pip install -e .
  • Figure out where pip put the scripts and add that folder to $PATH. In my case that would be adding this to my .bashrc:
export PATH=$PATH:~/.local/bin/

Then there are some environment variables competitive-programming-tools expects you to set:

TEMP:            temporary directory, typically /tmp
CPT_EXPAND_PATH: directories for which to expand includes,
                 separated by ':'

Tips and Tricks

Expanding local includes

The command

cpt expand file.cpp

prints the content of file.cpp with local includes (from the directory include in competitive programming tools) replaced with their contents recursively. This allows you to put data structures and algorithms in their own files and include instead of copy pasting.

Here is how i use it:

nnoremap <F9> :w<enter>:!echo %:p \| cpt expand - --tmp-file \| wl-copy<enter><enter>
nnoremap <F10> :w<enter>:!echo %:p \| cpt expand - \| wl-copy<enter><enter>

Putting these lines in the vim configuration lets you hit F9 to put the expanded source code in a temporary file, and copies the path of the temporary file to the clipboard. Hitting F10 puts the expanded source code directly in the clipboard. I use both because it differs between online judges wether submitting by pasting or by uploading a file is easier.

About

My tools for programming competitions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published