finds.dev← search

// the find

mitchellh/advent-2021-sql

★ 443 · PLpgSQL · Unlicense · updated Dec 2021

Advent of Code 2021 using SQL (PostgreSQL-flavored)

Mitchell Hashimoto (yes, that Mitchell Hashimoto) solving Advent of Code 2021 puzzles using only PostgreSQL SQL — no application code, no stored procedures, just CTEs and set operations. Self-imposed rules: single SQL statement per solution, ingest raw input directly, no plpgsql. Useful for anyone who wants to see what SQL can actually do when pushed.

The single-statement constraint forces genuinely interesting relational thinking — day 6 (lanternfish exponential growth) done as recursive CTEs is worth reading on its own. Raw input ingestion without preprocessing shows real PostgreSQL text-processing tricks (regexp_split_to_table, string_to_array, unnest) that transfer directly to production work. Docker Compose setup means you can run any solution in under two minutes. YouTube walkthroughs for each day are a rare addition that turns this from a code dump into something you can actually learn from.

Only 7 days completed — the repo stops mid-December and was never finished or retroactively completed as promised. No comments in the SQL itself, so without the videos the larger CTEs (day 5 line-drawing, day 4 bingo) require real effort to follow. His own input files are committed but AoC prohibits redistributing puzzle inputs, so you can't run solutions against his data if you don't have your own. Stars are high relative to content — this is a novelty repo, not a reference implementation.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →