This sentence contains three a’s, three c’s, two d’s, twenty-seven e’s, four f’s, one g, five h’s, eleven i’s, two l’s, sixteen n’s, seven o’s, five r’s, twenty-nine s’s, sixteen t’s, two u’s, six v’s, six w’s, six x’s, and three y’s.
What’s an autogram
An autogram is a self-referential sentence that writes out a count of its own characters - like the sentence above. You can count the number of occurrences of each letter in that first quoted sentence and verify it’s the same as claimed, or just trust that the sentence really does have three a’s, three c’s, two d’s, etc.
As you can imagine, constructing an autogram is challenging. The act of simply writing out how many of a particular letter is in a sentence changes the very letters that the sentence must describe. Consider how Lee Sallows, the inventor of autograms, describes searching for one by hand:
Suppose, for instance, a few day’s painstaking labour have at last yielded a near-perfect specimen: only the x’s are wrong. Instead of the five claimed, in reality there are 6. Writing six in place of five will not merely invalidate the totals for e, f, s, and v, the x in six means that their number has now become 7. Yet replacing six with seven will only return the total to 6. What now?
Lee Sallows - In Quest of a Pangram
I’m interested in constructing my own autograms from custom messages. For example, instead of a bland “This sentence contains…”, what about a birthday card to a friend: “Happy birthday, friend! This card contains exactly…”. Below I outline the steps I use to search for an autogram from a custom starting message.
A lot of what I’ve learned comes from Sallows’ essay on Reflexicons. He goes much more in-depth, and it’s worth a read if you want a deep dive. When I reference Sallows below it’s from this essay, unless I note otherwise.
So, what’s the autogram search process?
Self-descriptive cycles
Turns out there’s an easier generalization to finding one sentence that describes its own character count.
Find a self-descriptive cycle of sentences, where each sentence describes the character count of the previous.
A self-descriptive cycle of n sentences (period n) would look like:
- sentence 1
- sentence 2 → (describes) sentence 1
- …
- sentence n → sentence n-1
- sentence 1 → sentence n
Why is it easier to find a self-descriptive cycle?
The length of these sentences is bounded so there must be a finite number of them. This means that creating a sequence of sentences, each of which describes the previous one, is guaranteed to eventually produce a sentence that’s already in the sequence. Once one sentence repeats, the one sentence that describes it will also be a repeat of the sentence that described the first occurrence. After this the sequence is stuck in a loop of sentences which make up a self-descriptive cycle.
In short, counting the letter occurrences in this sentence and writing those out in the next sentence, then repeating, will always produce a self-descriptive cycle.
For example when I initiate with the phrase, “The previous sentence has”, my script proceeds with:
Epoch 0: The previous sentence has
Epoch 1: The previous sentence has one a, one c, five e's, two h's, one i, two n's, one o, one p, one r, three s's, two t's, one u, and one v.
Epoch 2: The previous sentence has three a's, two c's, one d, seventeen e's, one f, four h's, three i's, twelve n's, thirteen o's, two p's, three r's, nine s's, seven t's, two u's, three v's, and three w's.
Epoch 3: ...
After a few thousand iterations it lands in this monstrosity:
0000: The previous sentence has three a's, two c's, two d's, twenty-seven e's, six f's, three g's, seven h's, twelve i's, two l's, fourteen n's, eight o's, two p's, five r's, twenty-eight s's, seventeen t's, three u's, six v's, eight w's, four x's, and three y's.
0001: The previous sentence has three a's, two c's, two d's, thirty-two e's, four f's, four g's, ten h's, eight i's, two l's, eleven n's, eight o's, two p's, eight r's, twenty-nine s's, twenty-one t's, four u's, seven v's, eight w's, three x's, and three y's.
...
0314: The previous sentence has three a's, two c's, two d's, twenty-six e's, five f's, two g's, six h's, six i's, one l, fourteen n's, eleven o's, two p's, seven r's, twenty-nine s's, twenty t's, five u's, seven v's, nine w's, two x's, and three y's.
...
1618: The previous sentence has three a's, two c's, two d's, twenty-six e's, five f's, one g, five h's, eight i's, three l's, thirteen n's, eleven o's, two p's, seven r's, twenty-eight s's, seventeen t's, five u's, six v's, nine w's, five x's, and three y's.
...
ಠ_ಠ
...
1729: The previous sentence has three a's, two c's, two d's, thirty-two e's, three f's, one g, nine h's, seven i's, two l's, seventeen n's, ten o's, two p's, nine r's, twenty-four s's, twenty-one t's, three u's, six v's, nine w's, one x, and four y's.
...
2061: The previous sentence has three a's, two c's, two d's, twenty-seven e's, six f's, three g's, seven h's, twelve i's, two l's, fourteen n's, eight o's, two p's, five r's, twenty-eight s's, seventeen t's, three u's, six v's, eight w's, four x's, and three y's.
0001: The previous sentence has three a's, two c's, two d's, thirty-two e's, four f's, four g's, ten h's, eight i's, two l's, eleven n's, eight o's, two p's, eight r's, twenty-nine s's, twenty-one t's, four u's, seven v's, eight w's, three x's, and three y's.
0002: ...
See that? Sentences 2061 and 0000 are the same! Sentence 0001 describes both 2061 and 0000.
2061: The previous sentence has three a's, two c's, two d's, twenty-seven e's, six f's, three g's, seven h's, twelve i's, two l's, fourteen n's, eight o's, two p's, five r's, twenty-eight s's, seventeen t's, three u's, six v's, eight w's, four x's, and three y's.
0000: The previous sentence has three a's, two c's, two d's, twenty-seven e's, six f's, three g's, seven h's, twelve i's, two l's, fourteen n's, eight o's, two p's, five r's, twenty-eight s's, seventeen t's, three u's, six v's, eight w's, four x's, and three y's.
This is a self-descriptive cycle with a period of 2,061 sentences. Which I’m proud of because it’s fun to solve puzzles with code - but I won’t claim it’s elegant.
What is elegant, and the next logical step, is finding a cycle of fewer sentences - specifically a cycle of period 1. That is, one self-referential sentence that describes its own character count - an autogram.
The trick for a cycle of period 1
With a modification, this same iterative process can find autograms and avoid getting trapped in undesirable, large cycles. The trick comes from Sallows’ modification of a strategy he attributes to John R. Letaw.
As before construct a sequence of sentences. Only this time when constructing the next sentence in the sequence, alternate between:
- Updating all letter counts (as above)
- Updating one, random letter’s count and leaving all other letter counts the same as the previous sentence
Updating all letter counts (like when finding cycles) is helpful if the current iteration is one step removed from a cycle (hopefully of period 1). Updating just one letter’s count avoids getting stuck in any cycles of more than 1 and allows the process to run until it has found an autogram, if any exist. While cycles are guaranteed to exist for a given initiating phrase, there’s no guarantee that any of them are period 1.
In practice, if this technique doesn’t find an autogram after a few million iterations I adjust the initial wording and try again.
Autograms!
Happy birthday, friend! This card contains exactly seven a’s, two b’s, four c’s, five d’s, twenty-six e’s, nine f’s, two g’s, seven h’s, fifteen i’s, two l’s, nineteen n’s, eight o’s, three p’s, nine r’s, thirty s’s, seventeen t’s, four u’s, seven v’s, five w’s, four x’s, and six y’s.
Found on iteration 696,409 after 45 seconds.
Spam, Spam, Spam, six a’s, two d’s, twenty e’s, seven f’s, four g’s, five h’s, ten i’s, two l’s, five m’s, seven n’s, six o’s, five p’s, six r’s, thirty-one s’s, twelve t’s, three u’s, eight v’s, five w’s, four x’s, three y’s, eggs, and Spam.
Found on iteration 271,551 after 15 seconds.
At first this was taking a while, so I changed “egg” to “eggs” and got a solution fast.
The quick brown fox jumped over the alphabet soup containing four a’s, three b’s, three c’s, two d’s, thirty-five e’s, eight f’s, five g’s, ten h’s, twelve i’s, two j’s, two k’s, four l’s, two m’s, nineteen n’s, seventeen o’s, four p’s, two q’s, ten r’s, twenty-nine s’s, twenty-seven t’s, eight u’s, eight v’s, eleven w’s, two x’s, four y’s, one z.
Found on iteration 368,803 after 28 seconds.
Notice this one’s a pangram - i.e. includes all letters of the alphabet.
I am self referential! exclaimed the sentence as it enumerated its nine a’s, four c’s, four d’s, forty-four e’s, fourteen f’s, three g’s, ten h’s, nineteen i’s, five l’s, six m’s, twenty-three n’s, twelve o’s, four p’s, fifteen r’s, thirty-seven s’s, twenty-nine t’s, eight u’s, six v’s, seven w’s, six x’s, eight y’s, twenty-four comma’s, six hyphen’s, twenty-five apostrophe’s, and two !’s
Found on iteration 226,597 after 19 seconds.
This one includes punctuation, which can take the search process a while.
I had to try several initiating phrases before this one worked.
twenty e
four f
one g
five h
three i
one l
ten n
seven o
seven r
three s
nine t
three u
four v
three w
one x
two y
Found on iteration 208,117 after 8 seconds.
A nice, minimalistic, self-enumerating word list, or reflexicon as Lee Sallows dubbed them.
It includes only the 16 characters EFGHILNORSTUVWXY
which appear in number words below 100.
Sallows found 24 such cycles depending on how you start the iteration.
9 of those cycles are period 1 autograms.
Autogram-This is my GitHub repo with the Python I wrote to generate and validate autograms.
Here are some cool autogram related references and links I found:
- Lee Sallows Reflexicons essay
- In Quest of a Pangram includes Sallows’ very interesting description of first searching by hand, then engineering an autogram machine in 1983.
- autograms.net has lots of examples in lots of languages with lots of variety.
- A cool history of pangrams at fatrazie.com. The site is mostly in French but this article is English. If you let your browser automatically translates the page to English there are no real autograms left.
- Pangrammatic Autograms on the blog Papi Picante’s Spice Log describes finding autograms using an SAT-solver and also turns the post itself into an autogram.