문제
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.
예시
입력:
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.
입력:
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에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.