Abbreviate Long Words
sentence is a line of lowercase words separated by single spaces, or the empty string. Abbreviate every word that has more than limit letters: keep its first letter, then write the number of letters between the first and the last letter, then its last letter. Words with limit letters or fewer stay as they are. Return the new sentence, still separated by single spaces.
For example with limit = 4, internationalization becomes i18n and hello becomes h3o, while code stays code.
Example 1
internationalization has 20 letters, 18 of them between i and n; hard has only 4 letters, so it stays; is stays too.
Example 2
Only works is longer than 4 letters: w, then 3 middle letters, then s.
Constraints
0 <= len(sentence) <= 602 <= limit <= 10- words have lowercase letters only and are separated by single spaces, with no space at either end
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.