~/projects [h]

tom@pce:~$ ls ~/projects
1 traveling-salesmanFour ways to solve the traveling salesman problem, racing each other on the same cities. Brute force and dynamic programming find the guaranteed shortest round trip, a genetic algorithm and an ant colony approximate it in a fraction of the time. Add cities and watch the exact methods hit a wall while the heuristics keep going. genetic algorithmant colony optimizationrustpythonwasm 2 firefliesA swarm of fireflies, living their lives in a colony in a true ecosystem, or taking flight in a swarm of thousands. Each one only follows three rules over the friends it sees: don't crowd them, fly their way, stay close. Together that gives streams, swirls and flocks that split around rocks and scatter away from predators. rustwasmboidsswarm intelligence 3 kruskalKruskal's algorithm for the minimum spanning tree, built on hand-made data structures: a min binary heap hands out the edges cheapest first, a disjoint set with union by rank and path compression tells whether an edge joins two trees or would close a cycle. Watch the forest grow into a single tree, one edge at a time. binary heapdisjoint setrustpythonwasm 4 sudoku-solverA Sudoku solver, regular or diagonal, by constraint propagation: elimination, only choice and naked twins narrow the pencil marks down. When they get stuck, a depth-first search guesses in the cell with the fewest candidates and backtracks on a contradiction. Watch every step, or switch the strategies off and see how much more it has to guess. constraint propagationsearchrustpythonwasm 5 wayoflifeConway's Game of Life with a twist: every cell is new, a survivor or dying, each in its own colour, so you can follow how the grid evolves. The Python version grew from a naive grid into one that only looks at active cells and keeps neighbour counts up to date, sped up with Numba. A Rust port runs right here in the browser. numbapygamerustpythonwasm 6 aoc-rust-vs-pythonAdvent of Code 2024, day 1, taken far beyond the puzzle: Rust and Python side by side, from a straightforward solution to memory-mapped files, parallelism, SIMD and a bucket sort in Rust, and NumPy and Polars in Python. In the end, Rust processes 100 million lines, about 1.3GB, in less than a second. rustpythonsimdpolars 7 rust-etl-pipelineA streaming ETL pipeline in Rust: it reads a CSV file, processes the records and stores them in SQLite, with every stage running as its own async task, linked by channels. New data is read and processed while earlier batches are still being written, so no stage waits for another. rusttokiosqlxclap

tldr fireflies [2/7]

tom@pce:~/projects$ tldr fireflies

traveling-salesman

Four ways to solve the traveling salesman problem, racing each other on the same cities. Brute force and dynamic programming find the guaranteed shortest round trip, a genetic algorithm and an ant colony approximate it in a fraction of the time. Add cities and watch the exact methods hit a wall while the heuristics keep going.

traveling-salesman
stack
genetic algorithm, ant colony optimization, rust, python, wasm
uses
numpy, pygame, aiostream
used by
Traveling salesman problem
links
[video] [post]

fireflies

A swarm of fireflies, living their lives in a colony in a true ecosystem, or taking flight in a swarm of thousands. Each one only follows three rules over the friends it sees: don't crowd them, fly their way, stay close. Together that gives streams, swirls and flocks that split around rocks and scatter away from predators.

stack
rust, wasm, boids, swarm intelligence
links

kruskal

Kruskal's algorithm for the minimum spanning tree, built on hand-made data structures: a min binary heap hands out the edges cheapest first, a disjoint set with union by rank and path compression tells whether an edge joins two trees or would close a cycle. Watch the forest grow into a single tree, one edge at a time.

kruskal
stack
binary heap, disjoint set, rust, python, wasm
used by
Through the trees...
links
[post]

sudoku-solver

A Sudoku solver, regular or diagonal, by constraint propagation: elimination, only choice and naked twins narrow the pencil marks down. When they get stuck, a depth-first search guesses in the cell with the fewest candidates and backtracks on a contradiction. Watch every step, or switch the strategies off and see how much more it has to guess.

sudoku-solver
stack
constraint propagation, search, rust, python, wasm
links
[video]

wayoflife

Conway's Game of Life with a twist: every cell is new, a survivor or dying, each in its own colour, so you can follow how the grid evolves. The Python version grew from a naive grid into one that only looks at active cells and keeps neighbour counts up to date, sped up with Numba. A Rust port runs right here in the browser.

wayoflife
stack
numba, pygame, rust, python, wasm
uses
numpy, numba, pygame, opencv
used by
A way of life
links
[gitlab] [video] [post]

aoc-rust-vs-python

Advent of Code 2024, day 1, taken far beyond the puzzle: Rust and Python side by side, from a straightforward solution to memory-mapped files, parallelism, SIMD and a bucket sort in Rust, and NumPy and Polars in Python. In the end, Rust processes 100 million lines, about 1.3GB, in less than a second.

aoc-rust-vs-python
stack
rust, python, simd, polars
uses
polars, numpy
used by
Advent of Code Day 1: Rust versus Python
links
[post]

rust-etl-pipeline

A streaming ETL pipeline in Rust: it reads a CSV file, processes the records and stores them in SQLite, with every stage running as its own async task, linked by channels. New data is read and processed while earlier batches are still being written, so no stage waits for another.

rust-etl-pipeline
stack
rust, tokio, sqlx, clap
uses
tokio, futures, csv-async, sqlx, clap
used by
A basic Rust streaming ETL pipeline
links
[video] [post]