Try it
Countdown
A solver for the letters and numbers rounds of the TV game Countdown, written in Go. It started as a REST API on AWS. Now the same Go code runs in your browser as WebAssembly.
- Go
- WebAssembly
- Gin
- Docker
- AWS ECS
Try it
Press Solve. The first run downloads the solver and its dictionary, about 3.5 MB.
The idea
Countdown has two kinds of round. In the letters round you make the longest word from nine letters. In the numbers round you reach a target from six numbers with plus, minus, times and divide. Both are small search problems, which makes them a good project for a new language.
How it works
- Letters. The dictionary holds about 6 MB of words and definitions. It loads once and is sorted longest first. The search walks down that list and keeps each word that the nine letters can spell. So the first matches are the longest, and the top five come back with their definitions.
- Numbers. The search tries the six numbers with each operation in turn and drops duplicate expressions. It ranks the results by distance from the target, then by the shortest expression.
- 2023: a REST APIGin routes for /words and /numbers, in Docker on AWS ECS Fargate behind a load balancer, with autoscaling in CloudFormation.
- The cost of a serverThe load balancer and the container cost money every hour, even with no players.
- 2026: WebAssemblyThe same Go model package, compiled for the browser. A Web Worker runs it, so the page stays responsive during a search.
What I learned
- Keep the logic free of the framework. The solver uses only the Go standard library, so it compiled to WebAssembly with almost no changes.
- A small tool does not need a server. The browser does the work now, and it costs nothing to host.
- Tests make a move safe. 22 Go tests cover the solver, the handlers and the start-up. They still pass after the change.