Todos los desafíos
Fácil 0 resueltos 0% de aceptación

Acronym Generator

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

Problema

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.

Restricciones

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.

Ejemplos

Ejemplo 1
Entrada:
phrase = "central-processing unit"

Salida esperada:
expected = "CPU"
Entrada:
std::string phrase = "central-processing unit";

Salida esperada:
std::string expected = "CPU";
Entrada:
string phrase = "central-processing unit";

Salida esperada:
string expected = "CPU";

Explicación

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

Ejemplo 2
Entrada:
phrase = "don't repeat yourself"

Salida esperada:
expected = "DRY"
Entrada:
std::string phrase = "don't repeat yourself";

Salida esperada:
std::string expected = "DRY";
Entrada:
string phrase = "don't repeat yourself";

Salida esperada:
string expected = "DRY";

Explicación

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

Referencias

Este reto está adaptado para CodeUtility. Sigue el enunciado y las restricciones indicadas arriba.

Aprende de otros

Soluciones de la comunidad

Aún no hay soluciones publicadas. Resuelve este reto para compartir la primera.