Small competitive programming concepts and utilities
Project description
cp-snippets
Small, fast, and reusable competitive programming snippets for Python.
Built for GATE / ICPC / Codeforces / LeetCode preparation.
📦 Installation
pip install cp-snippets
🚀 Quick Start
from cp_snippets.arrays import binary_search
arr = [1, 3, 5, 7, 9]
print(binary_search(arr, 7)) # 3
📚 Modules Overview
| Module | Description |
|---|---|
cp_snippets.arrays |
Binary search, prefix sums, windows |
cp_snippets.bit_utils |
Bit manipulation helpers |
cp_snippets.dp |
Common DP templates (LIS, knapsack) |
cp_snippets.graphs |
BFS/DFS, DSU, Dijkstra, topo sort |
cp_snippets.io |
Fast input/output helpers |
cp_snippets.math_utils |
GCD/LCM, modular arithmetic, sieve |
cp_snippets.math |
Alias of cp_snippets.math_utils |
cp_snippets.misc |
Small helpers (ceil div, compression) |
cp_snippets.strings |
KMP/Z, rolling hash, Manacher |
cp_snippets.trees |
Fenwick, segment tree, LCA |
📖 Documentation
👉 Full API reference (auto-generated from docstrings): 🔗 https://srinivastls.github.io/cp_snippets/
The documentation is automatically generated using MkDocs + mkdocstrings and deployed via GitHub Actions.
🎯 Design Philosophy
- 🧠 Contest-friendly APIs
- ⚡ Minimal & fast
- 📘 Clear docstrings
- 🧩 Organized by topic
- 🧪 Easy to test and extend
🤝 Contributing
Contributions are welcome!
If you add a new snippet:
- include a clear docstring
- mention time complexity
- keep the API contest-friendly
📄 License
MIT License © Lakshmi Srinivas
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cp_snippets-1.0.0.tar.gz.
File metadata
- Download URL: cp_snippets-1.0.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd5c57d120345931bfddc9f619671b89b5a4a3edd7927dfcda230a424944ca24
|
|
| MD5 |
7f57144145460434acf58a31a0728d48
|
|
| BLAKE2b-256 |
e65263586643d39522199ca54584220d2d07a5fc2c6d805a85107d2faf1afaa9
|
File details
Details for the file cp_snippets-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cp_snippets-1.0.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
802ea93f697622a75529a51f305b0167e31579413213738d34b173ffe1f0d4fa
|
|
| MD5 |
d5ba7c0341bbbec7a985523b75661781
|
|
| BLAKE2b-256 |
e7df80ff43380a5622b225cfe8dd60bac9d6fe9e8fc1c897b3da5d1ddf00e246
|