Shorten very long words by replacing the middle with the count of removed characters.
You are given a list of words. For each word, if its length is greater than 10, replace it with a shortened form consisting of its first letter, the number of omitted middle characters, and its last letter. Otherwise, keep the word unchanged.
For example, localization becomes l10n because 10 characters are removed from the middle.
Return the transformed words in the same order.
Input Format
Input
- The first line contains an integer — the number of words.
- The next lines each contain one non-empty word.
Interpretation
For each word:
- if
len(word) <= 10, output the word as-is; - otherwise output: first character +
(len(word) - 2)+ last character.
Output Format
Output
Print lines. Each line should contain the transformed version of the corresponding input word.
Constraints
- Each word consists of lowercase English letters
- The length of each word is at least 1 and at most 100
Example 1
Input
4 word localization internationalization it
Output
word l10n i18n it
Explanation
Only words longer than 10 characters are abbreviated. Short words stay unchanged.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.