A numeronym is a word where numbers are used to form an abbreviation.
One specific way to do this is by replacing the letters between the first and the last letter with a number representing the number of letters omitted, such as in the numeronym i18n for internationalization. These word shortenings are called alphanumeric acronyms, alphanumeric abbreviations or numerical contractions.
In general, each number in the numeronym represents the number of letters omitted at that position. As such, se7en is a numeronym for semicitizen and R2D2 is a numeronym for random.
Write a function numeronym that takes a word $$w$$ (str) that only contains letters. If word $$w$$ has less than four letters, word $$w$$ (str) itself must be returned. Otherwise, the alphanumeric acronym (str) for word $$w$$ must be returned, where uppercase and lowercase letters are retained.
Write a function template that takes a word $$w$$ (str) that only contains letters and digits. The function must return word $$w$$ (str) in which all numbers have been replaced by the corresponding number of dots (.), where a number is a longest possible sequence of digits in the given word.
Write a function isnumeronym that takes two string (str) arguments: i) a word $$n$$ that only contains letters and digits and ii) a word $$w$$ that only contains letters. The function must return a Boolean value (bool) that indicates whether word $$n$$ is a numeronym of word $$w$$, where each number in word $$n$$ represents the number of letters omitted at that position. The function should not make a distinction between uppercase and lowercase letters.
>>> numeronym('internationalization')
'i18n'
>>> numeronym('TAKEDOWN')
'T6N'
>>> numeronym('Random')
'R4m'
>>> numeronym('DNA')
'DNA'
>>> template('i18n')
'i..................n'
>>> template('TAK3N')
'TAK...N'
>>> template('R2D2')
'R..D..'
>>> template('se7en')
'se.......en'
>>> isnumeronym('i18n', 'internationalization')
True
>>> isnumeronym('TAK3N', 'TAKEDOWN')
False
>>> isnumeronym('R2D2', 'Random')
True
>>> isnumeronym('se7en', 'semicitizen')
True
According to Tex Texin1, the first alphanumeric acronym was S12n — the electronic mail account name given to Digital Equipment Corporation (DEC) employee Jan Scherphuizen by a system administrator because his surname was too long to be an account name. By 1985, colleagues who found Jan's name unpronounceable often referred to him verbally as S12n (ess-twelve-en). The use of such numeronyms became part of DEC corporate culture.
When asked if he had a favorite math or logical puzzle, professor Donald Knuth — creator of the typesetting system $$\TeX$$2 for text and mathematical formulas — walked over to a white board, picked up a marker, and wrote the following:
"What's next?" he asked.