question 103 String Algorithms · easy
An acronym from an organisation's name
A report lists organisations by their acronyms: Consumer Financial Protection Bureau is CFPB. Build the acronym from the first letter of each word, in capitals. Hyphens separate words too (Run-Length Encoding is RLE). The small words of, and, the, for are skipped, except when one is the first word.
Function
acronym(name)Returnsthe capital first letters of the words, small words skipped unless first;
"" for a name with no wordsWordsseparated by any whitespace or by
-; small words are matched ignoring caseExamples
callacronym('Consumer Financial Protection Bureau')returns'CFPB'
callacronym('Bureau of Labor Statistics')returns'BLS'
callacronym('Run-Length Encoding')returns'RLE'