Skip to main content

A Codeforces CLI tool — fetch, display, and test against problems.

Project description

Disclaimer

This tool is not affiliated with Codeforces.

It fetches publicly available problem statements for personal use only. Users must comply with Codeforces Terms of Service: https://codeforces.com/terms

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

cf-tool

A fast, Codeforces CLI — fetch problems, display them cleanly, and test your solutions against sample cases, all from the terminal.


Features

  • cf get — fetch and display any Codeforces problem with clean Rich formatting
  • cf run — run your solution against all sample tests, with pass/fail output and diffs
  • Local cache — problems are saved to .cf_cache/ so repeated fetches are instant
  • Multi-language — Python, C++, C, Java, JavaScript, TypeScript, Ruby, Go, Rust
  • Smart ID inference — name your file 1829A.py and skip the --problem flag
  • Clean UX — spinner for loading, no fake delays, no excessive color

Installation

git clone https://github.com/yourname/cf-tool.git
cd cf-tool
pip install -e .

This registers the cf command globally.


Usage

Fetch a problem

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

Run your solution

# Specify the problem explicitly
cf run solution.py --problem 1829A

# Or name your file after the problem — ID is inferred automatically
cf run 1829A.py
cf run 2227D.cpp

# Custom time limit (milliseconds)
cf run solution.py -p 1829A --time-limit 2000

Manage the cache

cf cache list           # list cached problems
cf cache clear 1829A    # remove one problem
cf cache clear          # remove everything

Supported Languages

Extension Language How it runs
.py Python 3 python3 file.py
.cpp C++17 g++ -O2 then run
.c C gcc -O2 then run
.java Java javac then java
.js JavaScript node file.js
.ts TypeScript ts-node file.ts
.rb Ruby ruby file.rb
.go Go go run file.go
.rs Rust rustc -O then run

Project Structure

cf_tool/
├── cf_tool/
│   ├── __init__.py     # package version
│   ├── cli.py          # Typer CLI entry point
│   ├── scraper.py      # cloudscraper HTTP layer
│   ├── parser.py       # BeautifulSoup HTML → Problem
│   ├── runner.py       # subprocess test execution
│   ├── formatter.py    # Rich terminal output
│   ├── cache.py        # JSON local cache
│   ├── models.py       # Problem + TestCase dataclasses
│   └── utils.py        # LaTeX cleaning, ID parsing, normalization
├── pyproject.toml
├── requirements.txt
└── README.md

Exit Codes

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

This makes cf run composable in shell scripts and CI pipelines.


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.1.2.tar.gz (17.9 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.1.2-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cfmate-0.1.2.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for cfmate-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b59d9f4c044fd91690b580dbf8593c225a082c27bf79ef53bb4b3e214dffb0e5
MD5 f37ac9b5eb36267f76769f06aac121cf
BLAKE2b-256 46d545ff6ac145699ee8fe4c497de642fd544778df43aa31758c15bafcdb69ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cfmate-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for cfmate-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05631e8d5beaddb5818ed6f46e9b88d732fb34743f4af9c7f3149aa145a95f83
MD5 c7744e7ba2b9aa7c5bb811bd400517ff
BLAKE2b-256 6c247279e7db9da24b7f37c716a33cd2387cea910838b8a2df3394f672a32ae2

See more details on using hashes here.

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