A video editor’s caption track
Subtitlers work on a caption track: the lesson’s growing array, holding a film’s caption cues in order. Its buffer, from the checker’s plumbing, counts every cue written into a slot (a copy, a shift or a new cue), so the checker can tell a correct operation that is too slow from one that scales, however the code is written. Each level starts from the previous level’s finished code, so you can begin at any of them.
A teammate’s pull request adds the export step and a memory saving. The export worker hands each cue to the video renderer in order and must leave the track empty for the next reel. The change to remove gives memory back after big deletions. QA reports that exporting a feature film takes minutes, and that the editor stutters while a subtitler types and deletes a draft caption at the end of a long scene. You are reviewing the pull request.
An export’s time grows with the square of the cue count, and editing at certain lengths copies the whole track on every keystroke. Neither shows up on a short test reel.
Reproduce burnAll on a track of 2,000 cues returns them in order and leaves the track empty, but spends about two million moves. A track filled to exactly 8 cues that then gains and loses one draft caption 500 times copies all eight cues twice per round.
Acceptance criteria The export worker returns every cue in order and leaves the track empty and usable, within 2n moves for n cues. Adding and removing one cue at a track’s capacity boundary, again and again, costs at most a few moves per round. Memory is still given back: after removing most of a big track, its capacity comes down (to at most 64 when 10 of 1,000 cues remain). Everything from the earlier levels still works. Notes Cases print what the export worker returned (or a count and whether it was in order), the cues left, the capacity when it is the point, and whether the work stayed within its budget of moves. The buffer counts the moves, as before. Keep the track’s fields, its methods’ names and signatures, and the export worker’s; the checker calls them.