Skip to content

To Parse and Make Files For Competitive Programming Contest Problems

License

Notifications You must be signed in to change notification settings

Kaushal-26/Competitive-Companion-Helper-In-Go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

  1. Go to Releases
  2. Download the appropriate binary for your OS
  3. 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-Go binary 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

  1. Navigate to any competitive programming problem
  2. Click the Competitive Companion extension icon
  3. 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

  1. Check that Competitive Companion is installed and enabled
  2. Verify the port matches between CP Helper and the extension
  3. Ensure CP Helper is running before parsing problems
  4. Check browser console for errors

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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

About

To Parse and Make Files For Competitive Programming Contest Problems

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages