Swift exercises

Practice Swift by writing code

Open an exercise, edit the starter code, and run it on the server. Each drill ties back to interview topics—concurrency, collections, debugging, and more.

Tags

Reserve shared inventory without overbooking

Serialize a check-and-mutate operation and explain why protecting only the write is not enough.

SwiftConcurrencyGCD

Build a deterministic CI triage list

Filter noisy build records, sort the survivors by severity, and format stable output for reviewers.

SwiftCollections

Separate user-facing and debug descriptions

Make debugPrint useful for diagnosis while redacting sensitive values consistently.

SwiftDebugging

Aggregate server errors by endpoint

Build a dictionary from raw API events, then report required endpoints even when some have no failures.

SwiftCollections

Merge tag suggestions without losing priority

Normalize duplicate tag candidates, keep the strongest score per tag, and render a deterministic ranking.

SwiftCollections

Verify queue execution versus thread identity

Run a small script that shows why being on a dispatch queue is not the same thing as being off the main thread.

SwiftConcurrencyGCD

Predict method dispatch through a protocol type

Practice identifying when Swift uses dynamic dispatch for protocol requirements and when protocol extension methods are resolved statically.

SwiftProtocols