Einfach 0 gelöst 0% Erfolgsquote

Acronym Generator

Create an acronym from the first letter of every word, in uppercase.

Problem

Create an acronym from the first letter of every word, in uppercase. Spaces and hyphens separate words. Remove every other punctuation mark and digit without adding a separator; an apostrophe inside a word does not start another word. Ignore empty pieces.

Implement acronym_generator(phrase).

Input

phrase: The phrase to shorten.

Output

Return the uppercase initials in their original order.

Einschränkungen

0 ≤ phrase length ≤ 10,000. Input contains ASCII letters, digits, spaces, and punctuation; no tabs or line breaks. A phrase with no letters returns empty text.

Beispiele

Beispiel 1
Eingabe:
phrase = "central-processing unit"

Erwartete Ausgabe:
expected = "CPU"
Eingabe:
std::string phrase = "central-processing unit";

Erwartete Ausgabe:
std::string expected = "CPU";
Eingabe:
string phrase = "central-processing unit";

Erwartete Ausgabe:
string expected = "CPU";

Erläuterung

The hyphen and space separate central, processing, and unit. Their initials are C, P, and U.

Beispiel 2
Eingabe:
phrase = "don't repeat yourself"

Erwartete Ausgabe:
expected = "DRY"
Eingabe:
std::string phrase = "don't repeat yourself";

Erwartete Ausgabe:
std::string expected = "DRY";
Eingabe:
string phrase = "don't repeat yourself";

Erwartete Ausgabe:
string expected = "DRY";

Erläuterung

Remove the apostrophe to obtain dont. It is still one word, followed by repeat and yourself.

Referenzen

Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.

Von anderen lernen

Community-Lösungen

Noch keine veröffentlichten Lösungen. Löse die Aufgabe und teile als Erster eine Lösung.