Preparing your design workspace

Loading the problem and your latest saved attempt…

Design an Online Coding Competition Platform

Design a timed coding contest with reproducible sandboxed judging, deterministic scores, a fresh top-100 leaderboard, and exact personal rank outside the top list.

Problem statement

For this exercise, assume authenticated users register for scheduled two-hour individual coding contests. Each contest publishes one immutable version containing ten programming problems, hidden testcase versions, eight supported runtime-image versions, resource limits, and a scoring policy.

A contestant can run code against public examples without affecting rank or submit code for isolated judging against hidden tests. Submitted programs are untrusted: they have bounded CPU, memory, wall time, output, filesystem, process count, and no public-network or host access.

Each accepted run or submission is bound to the contest version and a stable client request key, so retries return one logical execution rather than scheduling another.

A reconnectable execution read exposes queued, running, or terminal status and, when terminal, bounded compilation diagnostics, score for a scored submission, runtime, memory, and failure reason without revealing hidden tests.

A terminal submission earns an integer score from 0 to 100 for one problem. Only the contestant's best score per problem contributes to the contest total.

Ties use lower total penalty, where each problem contributes the elapsed contest time when the contestant first achieved the counted best score; remaining ties use user ID. Ranking updates may be asynchronous, but every response identifies one ranking version.

The contest page returns the top 100 plus the viewer's exact score and rank from that same version, even when the viewer is outside the top 100. Connected clients may receive versioned top-list updates and must resynchronize after a gap.

Assume one contest may have 100,000 active contestants, with peaks of 20,000 public-example runs and 5,000 scored submissions per second across eight runtimes.

Durably acknowledge an accepted request within 500 milliseconds at p95, finish a typical healthy execution within 10 seconds at p95, serve leaderboard reads within 200 milliseconds at p95, expose accepted score changes in the top 100 within two seconds at p95 and in personal rank within five seconds at p95, and support 200,000 connected leaderboard subscribers.

During overload, preserve accepted scored submissions and allocate judge capacity fairly before best-effort public-example runs.

Per-user and per-contest admission quotas bound abusive traffic; security-sensitive actions and policy violations are auditable, and operators monitor admission, queue, sandbox, scoring, ranking, and close health.

At contest close, wait for every submission accepted before the deadline to reach a terminal outcome, then seal an immutable final ranking within five minutes.

Design contest and version storage, submission and execution state, sandbox scheduling, scoring, the authoritative participant aggregate, leaderboard indexing and delivery, personal-rank lookup, finalization, failure recovery, abuse controls, and observability.

Problem authoring, discussions, plagiarism adjudication, payments, team contests, global ratings, and live proctoring are outside scope.

What to build

  1. Contestants can view an active contest's immutable problems, supported runtimes, resource limits, scoring rule, and deadline.
  2. Registered contestants can idempotently run code on public examples or submit it for isolated hidden-test judging and retrieve durable status plus a bounded terminal result without hidden-test disclosure.
  3. The platform converts terminal judged submissions into one deterministic, replay-safe best score and penalty for each contestant.
  4. Contestants can retrieve the top 100 and their own exact rank from one ranking version and follow versioned top-list updates until final ranking is sealed.

At scale

  • For this exercise, assume one two-hour contest has 100,000 active contestants, ten immutable problems, and eight supported runtime images.
  • For this exercise, support peaks of 20,000 public-example runs and 5,000 scored submissions per second, acknowledge accepted requests within 500 milliseconds at p95, and finish a typical healthy execution within 10 seconds at p95.
  • For this exercise, serve leaderboard reads within 200 milliseconds at p95, show accepted score changes in the top 100 within two seconds at p95 and personal rank within five seconds at p95, and support 200,000 connected subscribers.
  • For this exercise, queues and workers may deliver or execute attempts more than once, but accepted submissions and scores are durable, and every pre-deadline submission reaches a terminal outcome before an immutable final ranking is sealed within five minutes.