rgoussu@goussu: ~/library/go/exercises
~/library/go/exercises cat protohackers-ladder.md

Protohackers ladder

# Climb Protohackers in Go — network servers from TCP echo to shared-state chat to a MITM proxy, one goroutine pattern per rung, race-detector clean.

Exercisesaved 2026-08-08source #exercise#go#networking#concurrency#goroutines#protohackers

Goal

Solve the Protohackers server-programming challenges in Go, in order. Each problem is graded by a live checker hammering your public endpoint, so correctness under concurrency is non-negotiable — exactly the muscle Go's goroutines-and-channels model exists for. Rule of the ladder: every rung passes go test -race and the online checker before the next begins.

Subject: full brief & instructions

Practices

  • Deep dive Go — goroutine-per-connection, channels vs. sync, context cancellation, the race detector: the concept's whole concurrency story.
  • Networking fundamentals — TCP vs. UDP semantics, framing, and byte-order, learned by being punished for guessing.
  • WebSockets & bidirectional protocols — the same long-lived-connection patterns these servers hand-roll.

Milestones

  1. Smoke Test. TCP echo server: accept loop, goroutine per connection, clean EOF handling. The skeleton every later rung reuses.
  2. Prime Time. Newline-delimited JSON protocol: bufio scanning, per-request validation, malformed-input responses — your first wire format.
  3. Means to an End. Binary protocol (9-byte messages, big-endian): encoding/binary, per-connection state, no shared state yet.
  4. Budget Chat. The shared-state rung: a chat room with joins, leaves, and broadcast. Solve it twice — once with a mutex-guarded map, once with a monitor goroutine owning the state via channels — and form an opinion.
  5. Unusual Database Program. UDP key-value store: datagram semantics, no connections, why retries and idempotency suddenly matter.
  6. Mob in the Middle. A malicious proxy rewriting Budget Chat traffic in flight: concurrent bidirectional copying, partial reads, and the tightest test of your framing discipline so far.

Stretch goals

  • Keep climbing: Speed Daemon and beyond are substantial distributed-ish builds.
  • pprof a server under checker load; find your allocation hot spots.
  • Re-solve one rung in Rust with Tokio and compare with Tokio mini-redis.

Related