Pangrams
The quick brown fox jumped over the lazy dog.
This is an example of a pangram - a sentence that contains every letter of the alphabet at least once.
A self-enumerating pangram is a sentence that fulfills the criteria to be a pangram by producing an analysis of its own letter count.
An example of achieving this is the sentence
This pangram contains four As, one B, two Cs, one D, thirty Es, six Fs, five Gs, seven Hs, eleven Is, one J, one K, two Ls, two Ms, eighteen Ns, fifteen Os, two Ps, one Q, five Rs, twenty-seven Ss, eighteen Ts, two Us, seven Vs, eight Ws, two Xs, three Ys, & one Z.
The Challenge
Produce a function with the input being the string leading into the letter inventory. In the example, the input would be "This pangram contains". The quantity of each letter must be in the written form and contribute to the displayed letter count.
Rules
- Oxford comma is optional
- Use an ampersand before Z (or, for hard mode, include the ability to switch between "&" and "and" in the function)
- Every letter counts towards the total letter count
- No non-written numbers
- This is code-golf so the shortest code in bytes wins
- In honour of the married couple this weekend, the numbers are to be written in the Queen's English. e.g.
nine hundred and ninety-nine Gs
for 999 occurrences of the letter G andnine hundred and nine Gs
for 909. - Orders of magnitude are to be written in the standard short-scale naming convention
Edge cases
- There are some cases where the code will get stuck in a loop - for example, if there are two Os the code will increase the count to three Os, which causes the code to count two Os again. If calculating every other letter before coming back to this can't resolve the issue, consider the input to be a false starter and output
false
,null
or an empty string. - If a letter has over 999 occurrences, the input should be considered a false starter.
Test Cases
- "This pangram contains" should output the example sentence
o
-s without the word for the count, then when you spell it out withtwo
, the whole string now has threeo
-s, meaning the word is now incorrect, switching it makes it incorrect again, etc. \$\endgroup\$Rob enjoys any sentence with two As, two Bs, two Cs, one D, thirty five Es, four Fs, three Gs, nine Hs, eight Is, two Js, one K, two Ls, one M, twenty two Ns, eighteen Os, one P, one Q, nine Rs, twenty three Ss, twenty three Ts, three Us, four Vs, eleven Ws, one X, seven Ys, & one Z.
\$\endgroup\$