Python3 implementation of competitive programming library inspired by spaghetti-source/algorithm.
-
These are my Python3 implementations of snippets and algorithms, which are written for studying/understanding algorithms.
-
These codes are published in public domain. You can use the codes for any purpose without any warranty.
-
Data Structure
- A dequeue that can perform random accesses with O(1)
- Alternatives to ordered set (set) in C++
- BIT (Binary Indexed Tree, Fenwick Tree) and inversion number
- Doubly Linked List
- Manage two-dimensional lists as one-dimensional lists
- Range Add Query (RAQ) and Range Sum Query (RSQ)
- Segment tree
- Self-balancing binary search tree using pivot values (ordered set in C++)
- Sorted multiset
- Sorted set
- Sum of top kth (the smallest / the largest)
- The K-th greatest value among the first i terms of P (i = K, K + 1, ..., n)
- Trie Tree
-
DP
-
Geometry
-
Graph
- Bellman Ford
- BFS (Breadth-First Search) template
- Cycle detection and reconstruct of directed and undirected graphs (first one only)
- DFS (Depth-First Search) template
- Dijkstra
- Is bipartite
- Lowest Common Ancestor
- Rooted Tree
- SCC (Strongly Connected Component)
- Topological Sorting
- Tree Distance
- Union Find Tree (1D and 2D)
- Union Find Tree (weighted)
- Warshall Floyd
-
Math
- Binary search
- Calculate rotation / reversal of coordinates using matrices
- Combination
- Compress coordinate
- Digit
- Direct product
- Extended Euclidean algorithm
- Factorization
- Generate divisors
- Interger carry
- Least Common Multiple (LCM)
- List of indices whose bit is 1
- Matrix rotation
- N-ary number
- Pascal's triangle (binomial coefficients, nCr)
- Permutation (nPr with mod)
- Prime
- Sort using key
- Ternary search
-
String
-
Technique
- Python 3.11.0+
- pip
- pytest
- GitHub Actions
- Install this repository by the following method.
- Search for snippets and algorithms as needed.
Paste the following commands at a Terminal prompt.
git clone https://github.com/KATO-Hiro/Somen-Soupy
Readme Driven Development; RDDarchive.org
Software licenses for competitive programming library