The standard library and third-party packages

F-PACKAGES-V4-3hard

Rename original labels

A noticeboard reads labels, removes one optional leading tag: marker, then applies a simultaneous rename table.

What needs to change

Repair rename so the label table applies simultaneously to the original cleaned labels.

Reproduce

  1. Use `clang++ -std=c++2c -Wall -Wextra -pedantic main.cpp -o program && ./program` with the ticket’s sample stdin; compare the renamed sequence with each original label’s expected destination.

Acceptance criteria

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

Notes

main.cpp supplies the cleaned vector, unique rename pairs and final report. Replacement names contain no whitespace; their punctuation is literal.

Input is LF/CRLF-delimited ASCII text: the first line contains labels, the second is a decimal rule count from 0 through 20, and each following rule line contains a source and destination separated by ordinary spaces or tabs. Surrounding space/tab framing and leading zeros or a plus sign on the count are accepted.

The first line has at most 50 labels. Each label, rule source and destination is a nonempty ASCII token of at most 64 characters without whitespace; each physical line is at most 4096 bytes. Rule sources are unique and destinations are nonempty literal text. The supplied reader receives valid data.

Cleaning can produce an empty label. It remains an original item in the rename operation, even though no rule has an empty source.

Sign in to open this exercise

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

Sign in