모든 챌린지
쉬움 0명 해결 정답률 0%

Acronym Generator

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

문제

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.

제약 조건

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.

예시

예시 1
입력:
phrase = "central-processing unit"

예상 출력:
expected = "CPU"
입력:
std::string phrase = "central-processing unit";

예상 출력:
std::string expected = "CPU";
입력:
string phrase = "central-processing unit";

예상 출력:
string expected = "CPU";

설명

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

예시 2
입력:
phrase = "don't repeat yourself"

예상 출력:
expected = "DRY"
입력:
std::string phrase = "don't repeat yourself";

예상 출력:
std::string expected = "DRY";
입력:
string phrase = "don't repeat yourself";

예상 출력:
string expected = "DRY";

설명

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

참고 자료

이 문제는 CodeUtility에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.

다른 사람의 풀이 보기

커뮤니티 솔루션

아직 공개된 풀이가 없습니다. 문제를 풀고 첫 풀이를 공유하세요.