/p/moul/x/daily/ahocorasick/v0
implements Aho-Corasick multi-pattern search as a pure, reusable package.
implements Aho-Corasick multi-pattern search as a pure, reusable package.
ports the core of Bitcoin's Base58 codec (à la mr-tron/base58 and btcutil/base58) to gno — as a reusable pure package.
implements RFC 4648 base32 and Crockford base32 as a pure, reusable package. Two alphabets, for two different jobs:
implements the Bech32 and Bech32m string formats of BIP-173 and BIP-350 as a pure, reusable package.
finds the cheapest route from one node to every other node of a weighted directed graph whose arcs may cost LESS than nothing, as a pure, reusable package.
implements bencoding, the serialization format BitTorrent uses for .torrent files and tracker responses, as a pure reusable package.
bidirectional map — unique in both directions — as a pure, reusable package. A normal map answers "what is the value for this key". A bidirectional one also answers the reverse in O(1), by keeping a second index.
dense, fixed-capacity bit vector as a pure, reusable package: a compact set of small non-negative integers with the usual set algebra (union, intersection, difference).
computes cliff-then-linear vesting schedules as a PURE calculator — no state, no balances, no transfers.
computes cliff-then-linear vesting schedules as a PURE calculator: no state, no balances, no transfers.
implements the commit-then-reveal scheme as a pure, reusable package.
estimates element frequencies in sublinear space, as a pure, reusable package. An exact frequency map costs one entry per distinct element, which on chain means unbounded storage driven by whatever users feed it.
on-chain Gno port of the classic `cowsay` program: it builds an ASCII cow with a speech bubble containing a message — as a reusable pure package.
on-chain Gno port of the classic `cowsay` program: it builds an ASCII cow with a speech bubble containing a message — as a reusable pure package.
implements the CRC-32 checksum as a pure, reusable package. CRC-32 treats a message as one enormous binary number and takes the remainder of dividing it by a fixed polynomial.
parses the classic five-field cron expression and answers the only question a schedule exists to answer: when does it next fire.
finds the cheapest route from one node to every other node of a weighted directed graph, as a pure, reusable package.
union-find (a disjoint-set forest) as a pure, reusable package: it tracks a partition of [0, n) into disjoint groups and answers "are these two in the same group?" in near-constant time.
Binary Indexed Tree (Peter Fenwick, 1994): an array of int64 that answers a prefix sum and applies a point update in O(log n), with no extra storage beyond the array itself.
sorted-vector map — the STL flat_map / Abseil btree_map trade — as a pure, reusable package. Keys and values live in two parallel sorted slices instead of a hash table or a tree of nodes.
exact rational arithmetic as a pure, reusable package: values are p/q with int64 numerator and denominator, always kept in lowest terms with a positive denominator.
encodes a latitude/longitude pair into the short base32 string known as a geohash, decodes one back into the cell it names, and walks from a cell to the eight around it.
matches shell-style patterns against strings, in two modes: plain, where `*` crosses everything, and path, where `/` is a boundary that only `**` crosses. The reason to have it on chain is the allowlist.
binary min-heap / priority queue over string items with integer priorities, as a pure, reusable package.
renders bytes in the classic xxd/hexdump -C layout, as a pure, reusable package.
compresses a string with canonical Huffman codes: the classic frequency-based prefix code, in the one form that is safe to put on a chain. Two properties matter here and neither is about compression. The codes are CANONICAL.
formats numbers for people rather than machines, as a pure, reusable package: byte sizes, thousands separators, ordinals, pluralisation and block-height "durations". Everything is integer-only.
formats numbers for people rather than machines, as a pure, reusable package: byte sizes, thousands separators, ordinals, pluralisation and block-height "durations". Everything is integer-only.
implements Knuth–Morris–Pratt substring search as a pure, reusable package. The naive scan re-compares characters it has already matched, so a hostile input like "aaaaaaab" in "aaaaaaaaaaaaaaab" costs O(n*m).
ports the classic Levenshtein edit-distance algorithm (as found in Go libraries like agext/levenshtein) to gno — as a reusable pure package.
implements the Luhn mod-10 checksum (Hans Peter Luhn, 1954) as a pure, reusable package: the check used by credit-card numbers, IMEIs and many national ID schemes to catch typos and single-digit transpositions.
deterministic Markov-chain text generator — a port of Go's canonical example "Generating arbitrary text: a Markov chain algorithm" (https://go.dev/doc/codewalk/markov/) with math/rand replaced by a caller-supplied seed.
bag / frequency counter — a set that allows duplicates and remembers how many — as a pure, reusable package.
implements MurmurHash3 x86_32, Austin Appleby's non-cryptographic hash, as a pure, reusable package. The function reads the input four bytes at a time.
computes the shortest edit script between two sequences of lines, using Myers' greedy algorithm: the same one git, diff and every review tool run to turn two documents into a list of additions and deletions.
map that remembers the order its keys were inserted, as a pure, reusable package. This matters more on chain than off it.
ports the classic "Pig Latin" translator — a staple Go beginner exercise — to gno.land as a reusable pure package. Rules implemented (the standard English game):
escrow ledger behind the pull-payment pattern, as a pure, reusable package. The pattern is the classic Solidity answer to reentrancy: never push value to an address, credit it and let the recipient withdraw.
escrow ledger behind the pull-payment pattern, as a pure, reusable package. The pattern is the classic Solidity answer to reentrancy: never push value to an address, credit it and let the recipient withdraw.
deterministic token-bucket rate limiter — a port of golang.org/x/time/rate with the wall clock replaced by a caller-supplied monotonic tick (on-chain, that tick is the block height).
deterministic token-bucket rate limiter — a port of golang.org/x/time/rate with the wall clock replaced by a caller-supplied monotonic tick (on-chain, that tick is the block height).
fixed-capacity FIFO that overwrites its oldest entry when full, as a pure, reusable package.
implements run-length encoding as a pure, reusable package: runs of a repeated byte collapse to a count and the byte. The encoding is `<count><char>` with counts in decimal, e.g. "aaabbc" → "3a2b1c".
pure port of the classic Roman-numeral converter kata: ToRoman / FromRoman, valid for 1..3999. Deterministic — no time, randomness or I/O — and free of any realm coupling, so it is reusable as a library.
ports Go's classic ROT13 example — the one used to teach strings.Map and io.Reader in the standard library docs — to gno as a reusable pure package.
rock-paper-scissors move: parsing it, naming it, and deciding a throw. It holds no state, so every realm that plays the game agrees on what "r" means and who wins.
on-chain port of the core of golang.org/x/mod/semver (and the spirit of github.com/Masterminds/semver): parse "vMAJOR.MINOR.PATCH [-prerelease][+build]" strings and compare them with correct Semantic Versioning 2.0.0…
implements SHA-1 (FIPS 180-1, RFC 3174) as a pure, reusable package: one-shot, streaming, HMAC-SHA1, and git object ids.
turns an infix arithmetic expression into reverse Polish notation and evaluates it over int64, with Dijkstra's shunting-yard algorithm (1961).
on-chain port of Go's classic concurrent prime sieve (the "prime sieve" example from the Go tour / Go source docs), implemented as a deterministic, allocation-friendly Sieve of Eratosthenes so it runs reproducibly…
implements the Soundex phonetic algorithm as a pure, reusable package: names that sound alike in English encode to the same four-character key, so "Robert" and "Rupert" both give R163.
renders a numeric series as one line of Unicode block characters — ▁▂▃▄▅▆▇█ — so a realm's Render can show a trend inline, with no image, no chart library and no client-side code. Everything is integer math, deliberately.
orders a dependency graph so that every node comes after everything it depends on — the "install these packages in a safe order" problem — as a pure, reusable package.
orders a dependency graph so that every node comes after everything it depends on — the "install these packages in a safe order" problem — as a pure, reusable package.
prefix tree (trie) for autocomplete, as a pure, reusable package: insert words, then ask for every word sharing a prefix.
implements LEB128 / protobuf-style variable-length integers over strings, with one deliberate restriction: it only accepts the canonical encoding of a value.