Tech News
← Back to articles

Solving Wordle with uv's dependency resolver

read original related products more articles

Introduction

In a previous life, I wrote a Sudoku solver that relied on Poetry's dependency resolver. We ended up selling that startup to EDB (not because of the Poetry hack), which means that they now own this IP. And, since then, Python packaging has advanced, with uv taking the world by storm.

This means that it's time for a refresh. Can we use uv instead of Poetry? And can we solve a Wordle instead of a Sudoku?

For the impatient: you can get the solver from my GitHub. Run uv run main.py run and watch it go.

Background: Sudoku and Python dependency resolution

The short summary of the Sudoku + Poetry post is that unlike Rust or JavaScript, a single Python project cannot use more than one version of a specific Python package. This means that we can easily represent a Sudoku grid as 81 Python packages, each with 9 possible versions. If a certain cell has a specific number (version), cells in the same row, column and a 3x3 square it belongs to cannot have that same number.

We can encode these rules as version constraints on other packages representing our cell's neighbours.

Once we have our 81 packages, all that remains is encoding our problem by making another package, specifying the precise versions of the cells where we already have numbers, leaving the rest as wildcards, and then letting Poetry generate a lockfile that will assign each number (version) to every cell (package), thus solving the puzzle.

What is Wordle

This is Wordle.

... continue reading