Intro
Given a whole number \$< 100,\$ extend/shorten the english representation of the number to have as many characters as it's value.
Rules
Take the number \$n\$, and get it in words from this dictionary. You may take this dictionary in any way you prefer. (a list, read from link, command line arg, STDIN, variable, so on.)
Here's the file as a JSON Array. (Courtesy of Lyxal)
Then, do the following with the string:
- If the string's length is lower than the number, repeat some of its characters in place until the length matches the number.
- The first and last characters should not be repeated, and the numbers of repetitions of the other characters should differ by at most one (so you can repeat some of them 5 times and others 6 times, for example; it doesn't matter which ones exactly).
- If the string's length is greater than the number, remove any of its characters except the first and last to make the length match the number. 1 and 0 are exceptions, since they are too small.
- The order of the letters in the string must be maintained.
- Example:
50 → f[ift]y → 3 letters must be duplicated 16 times
61 → s[ixtyon]e → 5 letters must be duplicated 10 times, 1 character must be duplicated 9 times
Step by step run-through
Taking 11 as an example,
(formatted as word → length
)
eleven → 6
^
elleven → 7
^
elleeven → 8
^
elleevven → 9
^
elleevveen → 10
^
ellleevveen → 11 (end)
Examples
2 → to
3 → the or tre or tee
4 → four
5 → fiive or fivve
7 → seevven or sevveen or seeveen
10 → teeeeeeeen
Special cases:
0 → (Any null value/no output)
1 → o
Winning Criteria
This is code-golf. Shortest code in each language wins.
LoTM Bounty Claimed by Dominic Van Essen!
The first Husk answer to this question will get a +50 rep bounty from me on top of Zgarb's bounty, if it satisfies the criteria put up here in the Additional Efforts part.
zero
? \$\endgroup\$remove any of its characters except the first and last to make the length match the number.
- this can't be done for 0 and 1, since with them you have to remove first/last letter for length to match the number. You should exclude 1 and 0 from that requirement. \$\endgroup\$