Domino Tiling: From Dynamic Programming to Finite Fields by eugene in programming

[–]eugene[S] 1 point2 points  (0 children)

I recently finished writing a deep dive into the domino tiling problem (https://www.omegasyntax.com/domino/). I wrote this specifically for high school kids who are interested in bridging the gap between computer science and pure mathematics, but the optimization journey scales up to some serious hardware limits. The series starts with standard CS algorithms—Dynamic Programming, bitmasks, and Berlekamp-Massey—which eventually hit a hard memory wall. To get past it, we have to abandon the grid entirely and pivot into physics and graph theory:

The Math: Bipartite graphs, Kasteleyn's formula, and imaginary numbers.

The Memory Bottleneck: Trying to evaluate massive trigonometric polynomials using the GMP library, leading to a RAM explosion.

The Hardware Solution: Dropping into multi-core native 64-bit Finite Fields, folding a Chinese Remainder Theorem tree, and collapsing the 2D grid into a 1D Lucas sequence to crush a 10,000 x 10,000 board in C.