Zig Through Problem Solving

Loading...
ProPart of the Pro catalogue.
6 decks66 cards

About this topic

This topic takes a problem-first approach to learning Zig. Instead of memorizing syntax in isolation, you'll reach for Zig's distinctive features — slices, optionals, error unions, allocators, comptime — exactly when a problem calls for them.

The 66 exercises are grouped into six themed decks, each building on the one before:

  1. 🔥 Warm-Up Classics — small integer and arithmetic problems that get you writing, compiling, and testing Zig without any new machinery in the way.
  2. 📏 Slices, Arrays, and Strings — the shape of data in Zig: indexing, slicing, in-place mutation, and byte-level string work with no hidden allocations.
  3. 📦 Collections Without Iterators — scanning, filtering, merging, and tallying with explicit loops, so you learn what Zig does instead of an iterator pipeline.
  4. 🎯 Optionals, Error Unions, Enums, and switch — absence and failure modelled in the type system: ?T, !T, orelse, try, custom error sets, and exhaustive switch.
  5. 🔒 Allocators and Owned Data — passing an allocator explicitly, pairing every allocation with defer/errdefer, and building stacks, queues, lists, and trees that own their memory.
  6. ⚡ Comptime, Generics, and Capstones — generic functions and data structures written with comptime, then three capstones that combine parsing, allocation, and error handling in one program.

Every card is a small function you implement against a test suite you run in the browser. Solutions are one click away when you're stuck, and the edge cases in each test teach as much as the happy path.

By the end, you'll have both solid Zig fundamentals — memory you manage on purpose, errors you can't ignore — and a toolkit of solutions to common programming challenges.

Decks