Todos os desafios
Fácil 0 resolvidos 0% de aceitação

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.

Restrições

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.

Exemplos

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

Saída esperada:
expected = "CPU"
Entrada:
std::string phrase = "central-processing unit";

Saída esperada:
std::string expected = "CPU";
Entrada:
string phrase = "central-processing unit";

Saída esperada:
string expected = "CPU";

Explicação

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

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

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

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

Saída esperada:
string expected = "DRY";

Explicação

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

Referências

Este desafio foi adaptado para o CodeUtility. Siga o enunciado e as restrições acima.

Aprenda com outros

Soluções da comunidade

Ainda não há soluções publicadas. Resolva este desafio para compartilhar a primeira.