Editor

Shorten Long Words

#517 · Strings · Beginner · 25 XP · about 3 min

Programmers sometimes shorten a very long word by keeping its first and last letters and writing, between them, how many letters were left out. So 'internationalization' becomes 'i18n', because 18 letters sit between the i and the n.

Write shorten(word) that does this for words longer than 10 letters. Words of 10 letters or fewer are returned unchanged.

Examples

shorten('internationalization')  # returns 'i18n'
shorten('localization')          # returns 'l10n'
shorten('accessibility')         # returns 'a11y'
shorten('python')                # returns 'python'

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.