6 kyu
Word a10n (abbreviation)
4,915 of 12,341wthit56
Description:
The word i18n
is a common abbreviation of internationalization
in the developer community, used instead of typing the whole word and trying to spell it correctly. Similarly, a11y
is an abbreviation of accessibility
.
Write a function that takes a string and turns any and all "words" (see below) within that string of length 4 or greater into an abbreviation, following these rules:
- A "word" is a sequence of alphabetical characters. By this definition, any other character like a space or hyphen (eg. "elephant-ride") will split up a series of letters into two words (eg. "elephant" and "ride").
- The abbreviated version of the word should have the first letter, then the number of removed characters, then the last letter (eg. "elephant ride" => "e6t r2e").
Example
abbreviate("elephant-rides are really fun!")
// ^^^^^^^^*^^^^^*^^^*^^^^^^*^^^*
// words (^): "elephant" "rides" "are" "really" "fun"
// 123456 123 1 1234 1
// ignore short words: X X
// abbreviate: "e6t" "r3s" "are" "r4y" "fun"
// all non-word characters (*) remain in place
// "-" " " " " " " "!"
=== "e6t-r3s are r4y fun!"
Strings
Fundamentals
Similar Kata:
Stats:
Created | May 16, 2014 |
Published | May 16, 2014 |
Warriors Trained | 41417 |
Total Skips | 11506 |
Total Code Submissions | 146064 |
Total Times Completed | 12341 |
JavaScript Completions | 4915 |
Haskell Completions | 306 |
Python Completions | 3773 |
Ruby Completions | 933 |
Java Completions | 1767 |
C# Completions | 849 |
Factor Completions | 9 |
TypeScript Completions | 117 |
Total Stars | 1002 |
% of votes with a positive feedback rating | 90% of 1579 |
Total "Very Satisfied" Votes | 1318 |
Total "Somewhat Satisfied" Votes | 218 |
Total "Not Satisfied" Votes | 43 |