Skip to main content

Small competitive programming concepts and utilities

Project description

cp-snippets

PyPI version Python versions Docs License

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

cp_snippets-1.0.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

cp_snippets-1.0.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

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

Hashes for cp_snippets-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fd5c57d120345931bfddc9f619671b89b5a4a3edd7927dfcda230a424944ca24
MD5 7f57144145460434acf58a31a0728d48
BLAKE2b-256 e65263586643d39522199ca54584220d2d07a5fc2c6d805a85107d2faf1afaa9

See more details on using hashes here.

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

Hashes for cp_snippets-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 802ea93f697622a75529a51f305b0167e31579413213738d34b173ffe1f0d4fa
MD5 d5ba7c0341bbbec7a985523b75661781
BLAKE2b-256 e7df80ff43380a5622b225cfe8dd60bac9d6fe9e8fc1c897b3da5d1ddf00e246

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