Composition and data transformation

F-PIPE-V4-2medium

Rank without reordering the queue

First connect the display steps in policy order: strip the leading The before shortening and adding brackets. Then show the top two requests by votes while retaining the arrival queue for refresh. Finally preview a one-vote promotion for every request without recording those votes in the queue.

What needs to change

Repair top_two so the ranking leaves the queue in arrival order.

Reproduce

  1. The starter does not compile; read the diagnostic before changing the code.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

The file contains its imports, read_lines, the Request struct, parse and the complete main.

Input: up to 50 song votes records, one per line, with ordinary spaces or tabs between fields. Song names are opaque non-whitespace UTF-8 tokens, including numeric-looking names. Votes are decimal nonnegative whole counts from 0 to 1000, including leading-zero spellings. An empty input has no requests; a request with zero votes is still present. The supplied readers receive valid data and do not validate these bounds.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in