A python library that contains standard competitive programming algorithms for faster access
Project description
cpalgo
The library is active since June 15, 2021.
Installation
Use the package manager pip to install foobar.
pip install cpalgo
Developers
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project Status
This project is expected to be completed by November 2021.
Templates to be covered in cpalgo
Algebra
Binary ExponentitationEGCD
Linear Diophantine Equations
Linear Sieves
Query based Optimisation
Sparse TableRMQ
Square Root Decomposition
Heavy Light Decomposition
RMQ - Euler Tour
Graph Optimisation
ArticulationDSU - Kruskal
Tarjan off-line
Fold Fulkerson - Max Flow
Dinic - Max Flow
Condensation Graph
Fenwick Tree
Segment Tree
Computational Geometry
Convex Hull - Graham's scanConvex Hull - Andrew Monotone
S&I NlogN
Lattice Points - Pick's algorithm
Documentation for cpalgo
Convex Hull
import cpalgo
points=[(x1, y1),(x2, y2)]
cpalgo.convex_hull(points)
Euler Phi
import cpalgo
n = 234
cpalgo.euler_phi(n)
Count Primes Sieves
import cpalgo
n = 234
cpalgo.count_primes(n)
Chinese Remainder Theorem
import cpalgo
a = 3; p = 29
cpalgo.chinese_remainder_theorem(a, p)
Levenshtein Distance
import cpalgo
s1 = "INTENTION"
s2 = "EXECUTION"
cpalgo.edit_distance(s1, s2)
Caesar Cipher
import cpalgo
s = "narayanaa"
key = 7
cpalgo.caesar_cipher(s, key)
nCr Modulus
import cpalgo
n = 71
r = 27
cpalgo.nCr_mod(n, r)
Unique Paths Combinations
import cpalgo
N = 21
M = 19
cpalgo.unique_paths(N, M)
Two Sum Target
import cpalgo
arr = [1, 2, 3, 4, 9, 14]
target = 18
cpalgo.two_sum(arr, target)
Three Sum Target
import cpalgo
arr = [1, 2, 3, 4, 9, 14]
target = 15
cpalgo.three_sum(arr, target)
Longest Common Subsequence
import cpalgo
s1 = "ALGORITHMS"
s2 = "RHYTHMS"
cpalgo.longest_common_subsequence(s1, s2)
Longest Increasing Subsequence
import cpalgo
nums = [1, 5, 4, 8, 2, 19, 30, 12, 92]
cpalgo.longest_common_subsequence(nums)
Longest Palindromic Substring
import cpalgo
string = "MADHAMAMAM"
cpalgo.longest_palindromic_substring(string)
Longest Palindromic Subsequence
import cpalgo
string = "MADHAMAMAM"
cpalgo.longest_common_subsequence(string)
Longest Common Prefix
import cpalgo
string = "MADHAMAMAM""
cpalgo.longest_common_prefix(string)
Word Break
import cpalgo
string = "applepenapple"
words = ["apple", "pen"]
cpalgo.word_break(string, words)
Minimum Window Substring
import cpalgo
string = "ADOBECODEBANC"
t = "ABC"
cpalgo.minimum_window_substring(string, t)
Maximum Subarray Sum
import cpalgo
arr = [1, 3, -2, 4, -6, 9, 2, -1, 3]
cpalgo.maximum_subarray(arr)
Maximum Product Subarray
import cpalgo
arr = [1, 3, -2, 4, -6, 9, 2, -1, 3]
cpalgo.maximum_product_subarray(arr)
Longest Substring Without Repetition
import cpalgo
string = "abcabcbb"
cpalgo.longest_substring_without_repetition(string)
Kth Largest Element - Heap
import cpalgo
arr = [1, 3, -2, 4, -6, 9, 2, -1, 3]
k = 4
cpalgo.kth_largest_element(arr, k)
Valid Parantheses
import cpalgo
string = "{{}{}{{}}{}"
cpalgo.is_valid_parantheses(string)
Is Palindrome
import cpalgo
string = "ANSIUISNA"
cpalgo.is_palindrom(string)
Smallest Missing Positive
import cpalgo
arr = [6, 3, -1, -9, 1]
cpalgo.first_missing_positive(arr)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cpalgo-1.1.1.tar.gz
(26.7 kB
view hashes)