README
ΒΆ
CP Helper - Competitive Programming Setup Tool
A powerful Go-based tool that automatically creates organized directory structures and files for competitive programming contests using Competitive Companion browser extension.
π Features
- Automatic Directory Structure: Creates organized folders by site β contest β problem
- Template Support: Use your favorite code templates for any programming language
- Test Case Management: Automatically generates input/output files from sample test cases
- Multi-file Support: Add helper files like Makefiles, debug scripts, or library files
- Problem Metadata: Saves problem information (time limits, memory limits, URLs) as JSON
- Cross-platform: Works on Windows, macOS, and Linux
- Real-time Logging: Detailed logs for debugging and monitoring
π Directory Structure
The tool creates a clean, organized structure:
contests/
βββ Codeforces/
β βββ 2142/
β β βββ A/
β β β βββ A.cpp # Your code file
β β β βββ 1.in # Sample input 1
β β β βββ 1.out # Sample output 1
β β β βββ 2.in # Sample input 2
β β β βββ 2.out # Sample output 2
β β β βββ problem.json # Problem metadata
β β β βββ Makefile # Extra files
β β βββ B/
β β βββ ...
β βββ 1959/
β βββ ...
βββ AtCoder/
β βββ abc335/
β β βββ abc335_a/
β β β βββ abc335_a.cpp # Your code file
β β β βββ ...
β βββ ...
βββ CodeChef/
β βββ START115A/
β β βββ PROBLEM_NAME/
β β β βββ PROBLEM_NAME.cpp # Your code file
β β β βββ ...
βββ ...
π Installation
Option 1: Download Binary
- Go to Releases
- Download the appropriate binary for your OS
- Add to your PATH
Option 2: Build from Source
git clone https://github.com/Kaushal-26/Competitive-Companion-Helper-In-Go.git
cd Competitive-Companion-Helper-In-Go
go install
- Make sure GOBIN is set with PATH
# ~/.bashrc or ~/.zshrc export GOBIN=$HOME/bin export PATH=$PATH:$GOBIN - Now we can use
Competitive-Companion-Helper-In-Gobinary anywhere inside our terminal.
π― Quick Start
1. Install Competitive Companion
Install the browser extension:
2. Configure the Extension (OPTIONAL)
Set the port in Competitive Companion to your custom port if require, 27121 (default).
3. Start CP Helper
# Basic usage
Competitive-Companion-Helper-In-Go
# With custom settings
Competitive-Companion-Helper-In-Go --port 27121 --path ./my-contests --template template.cpp
# Check all flags
Competitive-Companion-Helper-In-Go --help
4. Parse Problems
- Navigate to any competitive programming problem
- Click the Competitive Companion extension icon
- Files are automatically created in your specified directory!
π Usage Examples
Basic Setup
Competitive-Companion-Helper-In-Go --path ./contests
With C++ Template
Competitive-Companion-Helper-In-Go --template ~/templates/template.cpp --path ./contests
With Multiple Helper Files
Competitive-Companion-Helper-In-Go \
--template template.cpp \
--extra-files Makefile,debug.h,testlib.h \
--path ./contests
Custom File Extensions
Competitive-Companion-Helper-In-Go \
--input txt \
--output ans \
--template solution.py
Different Port
Competitive-Companion-Helper-In-Go --port 12345 --path ./competitive-programming
βοΈ Command Line Options
| Flag | Short | Default | Description |
|---|---|---|---|
--port |
-p |
27121 |
Server port for Competitive Companion |
--path |
. |
Base directory for contest folders | |
--template |
-t |
Template file for code submissions | |
--input |
in |
File extension for input test cases | |
--output |
out |
File extension for output test cases | |
--extra-files |
Additional files to include in each problem |
π Template Examples
C++ Template (template.cpp)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define all(x) x.begin(), x.end()
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// Your code here
return 0;
}
Python Template (template.py)
import sys
from collections import defaultdict, deque
from math import gcd, lcm
def solve():
# Your solution here
pass
if __name__ == "__main__":
solve()
Java Template (template.java)
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Your code here
sc.close();
}
}
π§ Advanced Configuration
Makefile Example
Create a Makefile to include as an extra file:
CXX = g++
CXXFLAGS = -std=c++17 -O2 -Wall -Wextra -Wshadow
TARGET = $(shell basename $(CURDIR))
SOURCE = $(TARGET).cpp
$(TARGET): $(SOURCE)
$(CXX) $(CXXFLAGS) -o $@ $<
test: $(TARGET)
./$(TARGET) < 1.in
clean:
rm -f $(TARGET)
.PHONY: test clean
Debug Header Example (debug.h)
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = [", _debug(x)
#else
#define debug(x...)
#endif
void _debug() { cerr << "]" << endl; }
template<class T, class... U>
void _debug(T a, U... b) {
cerr << a;
if(sizeof...(b)) cerr << ", ";
_debug(b...);
}
π Supported Platforms
- Codeforces (all contest types)
- AtCoder (ABC, ARC, AGC, etc.)
- CodeChef (all contest formats)
- TopCoder (SRMs, TCO)
- HackerRank (contests and practice)
- LeetCode (contests)
- Google Code Jam / Kick Start
- Facebook Hacker Cup
- And many more supported by Competitive Companion!
π¨ Troubleshooting
Port Already in Use
# Use a different port
Competitive-Companion-Helper-In-Go --port 12345
# Don't forget to update Competitive Companion settings
Permission Denied
# Make the binary executable
chmod +x Competitive-Companion-Helper-In-Go
# Or run with appropriate permissions
sudo Competitive-Companion-Helper-In-Go --path /usr/local/contests
Template Not Found
# Use absolute path
Competitive-Companion-Helper-In-Go --template /home/user/templates/template.cpp
# Or relative path from current directory
Competitive-Companion-Helper-In-Go --template ./templates/template.cpp
Extension Not Working
- Check that Competitive Companion is installed and enabled
- Verify the port matches between CP Helper and the extension
- Ensure CP Helper is running before parsing problems
- Check browser console for errors
π€ Contributing
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
git clone https://github.com/Kaushal-26/Competitive-Companion-Helper-In-Go.git
cd Competitive-Companion-Helper-In-Go
go mod tidy
go run main.go --help
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- jmerle for the amazing Competitive Companion extension
- The competitive programming community for inspiration and feedback
- Go community for excellent libraries and tools
Documentation
ΒΆ
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.