Skip to main content

A fast Codeforces CLI tool for fetching problems and testing competitive programming solutions

Project description

cfmate — Fast Codeforces CLI for Competitive Programming

cfmate is a fast, developer-friendly CLI tool for Codeforces that lets you fetch problems, view them in a clean format, and test your solutions directly from the terminal.

It is designed to eliminate context switching and streamline the competitive programming workflow.


🚀 Why cfmate?

Competitive programming usually involves:

  • switching between browser and editor
  • manually copying test cases
  • repeatedly fetching problem statements

cfmate solves this by bringing everything into your terminal.

With cfmate, you can:

  • fetch problems instantly
  • run solutions with sample tests
  • cache problems locally for speed
  • stay fully inside your development environment


🆕 New Features

🔎 Problem Explorer

Browse all Codeforces problems with fuzzy search:

cf explore

Pre-filter by tag or keyword:

cf explore -e dp
  • Search by problem name, tags, or rating
  • Fast fuzzy matching
  • Navigate using keyboard
  • Press Enter to fetch problem instantly

📚 Contest Browser

Open a contest and select problems interactively:

cf get 2227
  • Shows all problems in the contest
  • Navigate with arrow keys
  • Press Enter to fetch selected problem

🌍 Global Problem Cache

A global problem dataset is now stored at:

~/.cfmate/problems_cache.json
  • Enables fast searching in cf explore
  • Loaded instantly after first fetch

🔄 Update Problem List

Refresh the global problem dataset:

cf update -p
  • Fetches latest problems from Codeforces API
  • Recommended occasionally to stay up-to-date

⚡ Enhanced Create Command

Improved project scaffolding:

cf create 2227
cf create 2227A py
cf create A py
  • Supports folder-only, file-only, and combined modes
  • Automatically detects contest context
  • Saves preferred language
  • Optionally pre-fetches problem into cache

🧠 Improved Architecture

  • Introduced a core.py module for shared logic
  • Clean separation between CLI, UI, and core logic
  • Improved maintainability and scalability

✨ Features

🔍 Problem Fetching

Fetch any Codeforces problem directly:

cf get 1829A
  • Displays formatted problem statement
  • Includes input/output format
  • Shows sample test cases
  • Uses clean terminal rendering

🧪 Solution Testing

Run your solution against sample tests:

cf run solution.py --problem 1829A
  • Executes all sample test cases
  • Shows pass/fail results
  • Displays clear output differences
  • Returns proper exit codes (useful for scripting)

⚡ Smart Caching System

  • Problems are stored locally in .cf_cache/
  • Eliminates repeated network requests
  • Provides instant access after first fetch

🧠 Smart Problem Detection

You don’t always need to specify the problem:

cf run 1829A.py
  • Automatically extracts problem ID from filename
  • Reduces command verbosity

🌐 Multi-language Support

Supports multiple programming languages:

Language Execution
Python python3 file.py
C++ g++ -O2 then run
C gcc -O2 then run
Java javac + java
JavaScript node file.js
TypeScript ts-node file.ts
Go go run file.go
Rust rustc -O then run
Ruby ruby file.rb

🎯 Clean Developer Experience

  • Minimal and readable terminal output
  • No unnecessary clutter
  • Fast execution and feedback loop

📦 Installation

Install directly from PyPI:

pip install cfmate

⚡ Quick Start

1. Fetch a problem

cf get 1829A

2. Solve it in your editor

Create a file:

1829A.py

3. Run tests

cf run 1829A.py

📘 Detailed Usage

Fetching Problems

cf get <problem_id>

⚠️ If cf get is not working or shows a loading/Cloudflare error, run:

playwright install chromium

This installs the browser required for fetching problems.

Examples:

cf get 1829A
cf get 2227D --no-cache

Options:

  • --no-cache → force re-fetch from Codeforces

Running Solutions

cf run <file> [options]

Examples:

cf run solution.py --problem 1829A
cf run 1829A.py
cf run 2227D.cpp

Options:

  • --problem / -p → specify problem ID manually
  • --time-limit → override execution time limit

Example:

cf run solution.py -p 1829A --time-limit 2000

Creating Files and Folders

cf create <target> [lang]

Modes:

cf create 2227        # create contest2227/ folder
cf create A py        # create 2227A.py inside current contest folder
cf create 2227A py    # create folder + file

Behavior:

  • Creates contest<id>/ folder if not present
  • Generates file using language template
  • Automatically infers problem ID
  • Optionally fetches and caches the problem

Cache Management

cf cache <command>

Commands:

cf cache list
cf cache clear 1829A
cf cache clear

🗂 Cache System (Detailed)

Location

Cache is stored in:

.cf_cache/

Each problem is stored as a JSON file:

.cf_cache/
  ├── 1829A.json
  ├── 2227D.json

When using cf create, cache is stored inside the contest folder:

contest2227/
  ├── 2227A.py
  └── .cf_cache/
      └── 2227A.json

Cache Behavior

Scenario Behavior
Not cached Fetch from Codeforces and store
Cached Load instantly
Corrupted cache Re-fetch automatically
--no-cache used Skip cache and overwrite

Benefits

  • Faster repeated runs
  • Reduced network usage
  • Offline access after first fetch

🧪 Exit Codes

Code Meaning
0 All tests passed
1 One or more tests failed

Useful for:

  • scripting
  • CI pipelines
  • automation

⚠️ Disclaimer

This tool is not affiliated with Codeforces.

It fetches publicly available problem statements for personal use only. All problem content belongs to Codeforces: https://codeforces.com

Users are responsible for complying with Codeforces Terms: https://codeforces.com/terms

This tool does not store or redistribute problems beyond local caching.


🔗 Links


📄 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfmate-0.3.2.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cfmate-0.3.2-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file cfmate-0.3.2.tar.gz.

File metadata

  • Download URL: cfmate-0.3.2.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cfmate-0.3.2.tar.gz
Algorithm Hash digest
SHA256 ab5adf3b81f0bbe9d4f46d5802e9293d77e775bab2901d867f6bb422b12680b2
MD5 56509975a6b68524cc508ce82260ef09
BLAKE2b-256 d2e3b8dc18207dadd4c63b9015655b48a08d374aaf59ef13d11a97029c90da72

See more details on using hashes here.

Provenance

The following attestation bundles were made for cfmate-0.3.2.tar.gz:

Publisher: publish.yml on Saksham-cmd-tech/cf_tool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cfmate-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: cfmate-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cfmate-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c44bbc93f17e02a6b00857b1e04bfa6a599dea21e54edcea2233d733124e1562
MD5 dfba6da81a3b8f812aee9569cbb82f67
BLAKE2b-256 eab72356d2f95b951584552233aad0d88c0d73be81d34c9addff8f87aa3d053c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cfmate-0.3.2-py3-none-any.whl:

Publisher: publish.yml on Saksham-cmd-tech/cf_tool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page