Skip to main content

pydsa

Data structure and algorithm helpers for LeetCode-style Python: the functions one keeps rewriting at the top of a solution, written once and tested.

pip install pizza-lib   # the import name is pydsa
from pydsa import table, cells, nbrs, first_true, Multiset, maxheappush

dp = table(3, 4)                      # a 3 by 4 grid of zeros
for i, j in cells(grid):              # every cell, row by row
    for ni, nj in nbrs(grid, i, j):   # its on-grid neighbours
        ...
first_true(1, 10**9, lambda x: x * x >= n)   # the first x in [1, 10^9] with ok(x)

Modules

Module Names
grid table, like, shape, cells, nbrs, in_bounds, is_edge, edges, put, row, col, set_row, set_col, grid_bfs, CARDINALS, DIAGONALS, ALL_EIGHT
adj adjacency, indegrees, levels, components, Graph, graph, dijkstra
search first_true, last_true, first_false, last_false, min_chunks, viz_binary_search
heaps maxheappush, maxheappop, maxheapify, maxheappushpop, maxheapreplace, maxheappeek, maxheapitems, heap, draw_heap
counting Multiset, count_pairs
combo pairs, triples
digits to_digits, to_int, even, odd
arith ceil_div, batched
seq lcs
generators as_list
nodes TreeNode, ListNode, GraphNode, Node
tree build_tree, get_level_order, find_node, get_inorder, is_balanced, build_nary_tree, build_general_tree, get_general_tree, generate_random_tree, generate_full_binary_tree, draw_tree, draw_general_tree
bst insert, generate_random_bst, tree_to_list, is_valid_bst, generate_and_print_random_bst
linked build_linked_list, get_list_values, print_linked_list, linked_list_reverse_k, draw_linked_list
graphs build_graph, get_adj_list, build_graph_from_edge_list, as_dict_of_dicts, is_edge_list, draw_graph, draw_graphviz, draw_ascii_graph

Every public name is importable from the package itself. The package imports only the standard library. The draw_* functions, tabulate-style output and viz_binary_search import rich, colorama, PrettyPrintTree and graphviz when first called:

pip install 'pizza-lib[draw]'

Every function has a docstring with its contract; the tests in tests/ are the examples.

Where it comes from

These helpers were the harness of the leet repo, preloaded into builtins for every solve there, and the library that the mu language pastes into the Python it emits. Both still use them from here.

Tests

pip install -e '.[test]'
pytest

Metadata

Release files for pizza-lib 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pizza-lib 0.1.0
File Size Uploaded Provenance Actions
pizza_lib-0.1.0.tar.gz 31.2 kB Without provenance Details for pizza_lib-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pizza-lib 0.1.0
File Interpreter ABI Platform Actions
pizza_lib-0.1.0-py3-none-any.whl Python 3 none any Details for pizza_lib-0.1.0-py3-none-any.whl

Total release size: 60.6 kB

Release files / pizza_lib-0.1.0.tar.gz

Download URL pizza_lib-0.1.0.tar.gz
Size 31.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b4d8083383e8ffae7c54ed46f16dc1027100d32d9b93c9f04e7bf3a462594b37
BLAKE2b-256 checksum
How to use checksums
854acd743a68e78f7f25084eec9fe18906a9f7f280d7455439cb3a49d4ade9d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pizza_lib-0.1.0-py3-none-any.whl

Download URL pizza_lib-0.1.0-py3-none-any.whl
Size 29.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a499799eb805d142549ca3e48b71bdc0032a6a087b5f12b08810ac91037aa376
BLAKE2b-256 checksum
How to use checksums
59ffe2a25a4c2d0b5892eed7f0aaf30f5b618cf29fda9804f5e1cca5b9b68b9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pizza-lib 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page