C++20 sections · 1024 units
Open in Course

Way Too Long Words - Algorithm

How to solve

For each word, follow these steps:

1.1. Read the word from input.

2.2. Check its length. If length is 10 or less, print the word unchanged.

3.3. If length exceeds 10, construct the abbreviation: first character, then (length - 2) as a number, then last character. The length minus 2 calculation gives you the count of middle characters that get replaced. For "internationalization" (20 chars), the middle count is 20 - 2 = 18, giving "i18n".