The value is right. Is the state?
Trace the program. Choose a test that can expose the defect.
Margin Notes is a fictional documentation app. All code, operations and expected states are authored teaching data.
The cache contract
- Keys are strings. Stored values are positive integers; null means a missing key and is never stored.
- Map order is least recent first. A successful get moves its key last; a miss changes nothing.
- put adds or updates a value and moves its key last. An overwrite uses one slot. When size exceeds capacity, remove the oldest key.
- Each trace begins empty. This packet covers local caches of capacity one or two, without concurrency or expiration.
What the desk checks
The desk calls three fixed authored variants. It never evaluates code or other text you enter. The displayed functions come from that same module. Expected states were authored separately from those functions. Five matching traces support a bounded result; they do not prove every input or a hiring outcome. Notes stay in this page's memory.
Read the worked case →