#P7694. Transform Long Compound Names to Short Variants
Transform Long Compound Names to Short Variants
Transform Long Compound Names to Short Variants
In many scientific papers, it is common to find two different naming conventions when citing early works. The two conventions are :
- Long variant: The full surnames of the authors connected by hyphens (e.g.
Knuth-Morris-Pratt
). - Short variant: Only the first characters of each surname concatenated together (e.g.
KMP
).
You are given a text that may contain long variants alongside other text. Your task is to convert each occurrence of a long variant into its corresponding short variant.
A long variant is defined as a sequence of two or more words (containing only letters) joined by hyphens. To transform such an occurrence, split it by hyphen and concatenate the first character of each part. If no hyphen is found in a word, it should remain unchanged.
For example, if the input contains Knuth-Morris-Pratt
it should be transformed into KMP
.
Note: All formulas, if any, should be in LaTeX format. For example, the transformation can be conceptually represented as:
$$\text{Short} = \prod_{i=1}^{n} \text{first}(\text{word}_i)$$
inputFormat
The input consists of a single line containing a string of text. The text may include long variant names in the format described above.
Input Format:
A single line of text.
outputFormat
Output the modified text, where each long variant is replaced by its corresponding short variant.
Output Format:
A single line of text after performing the required transformation.
sample
Knuth-Morris-Pratt
KMP