← Back to problems
UNSW COMP2041 · medium

22T2 Q6 — Reorder names (Last, First → First Last)

Each stdin line is a name Surname, Given names possibly with trailing whitespace. Rewrite it to Given names Surname, preserving the trailing whitespace. Lines not matching <x>, <y> are output unchanged.

Costner, Kevin Augustus ·  →  Kevin Augustus Costner ·

(· marks a preserved trailing space.) Concrete layout pinned here (exam source had only a digest).


Python only. From COMP2041/9044 — adapted for autotest.