← back to blog

NandGame: build a computer from a single logic gate

code

Right, I want to tell you about NandGame because I’ve been playing it on and off for years and I don’t think enough people know it exists.

It’s free. It runs in the browser. The premise is this: build a computer from scratch, starting from a single logic gate — a NAND gate. That’s it. One component. Go.

From that you build NOT gates, AND gates, OR gates, XOR gates. Then half adders, full adders, an ALU. Then registers. Then RAM. Then a program counter. Then a fully programmable computer. All of it wired together by you, in a little drag-and-drop circuit editor, level by level.

I work in cyber security, ive done years of infracstructure stuff, I fiddle with tech all the time yet somehow I am and have always been several layers of abstraction away from caring about logic gates. And yet. Every few months something reminds me NandGame exists and I lose an evening to it.

Because here’s the thing — it’s not just educational (though it is (relay start point aside), genuinely, the most intuitive explanation of how a computer actually works that I’ve encountered). It’s a puzzle game. A good one. There’s a minimum component count for each solution and once you clear a level you will absolutely go back and try to do it in fewer gates because your first solution was technically correct and aesthetically offensive.

The difficulty curve is right too. The early stuff feels obvious in retrospect, which is how it should feel — you want to feel clever, not battered. By the time you’re thinking about memory addressing and how a program counter actually increments and why, you’ve built up enough context that it makes sense. It doesn’t feel like a lesson. It feels like a thing you worked out. Best part is, when you get stuck, as you will, and even after completing it I still do when I re-visit - someone, somewhere has already worked it out, reddit is a trove of the right answers if you are really stuck and can give yourself the easy way out without much guilt - because even when you know the answer, its still hugely interesting to see it and realise how and why it works.

If you’ve ever wondered how the thing you write code on actually works — not in a “well there’s electricity and silicon” hand-wavy way but actually, concretely, step by step — go play it. It’s free. It takes as long as you let it take. You’ll come out the other end knowing what an ALU is and why that matters, which is more than most CS degrees bother to explain before they move on to talking about algorithms.

nandgame.com. Go on. You won’t regret it. I mean you might lose a Tuesday evening but that’s a reasonable price.