A recent XKCD caused some amusement: “Vocabulary update: I learned another word today, bringing my total to twelve”.

We wondered whether there might be possible formulations of this joke that also contained the unique character count, so I wrote the following python script:

import num2word
import numpy

def find_self_reference():
    sentence = "I learned another word today bringing my total to {0} words and {1} letters"
    words = 12

    for i in range(0, 1000):
        num_word = num2word.word(i)
        final_words = words + numpy.char.count(num_word, " ") + 1
        final_num_words = (
            int(final_words)
            + int(numpy.char.count(num2word.word(int(final_words)), " "))
            + 1
        )

        sentence_sub = sentence.format(num2word.word(final_num_words), num_word)
        characters = len(set(sentence_sub.replace(" ", "")))

        print(f"Needed {characters} characters but got {i}.")

        if characters == i:
            print(sentence_sub)
            return

This gives us the following results:

  • I learned another word today bringing my total to fourteen words and twenty letters

or

  • Vocabulary update: I learned another word today bringing my total to seventeen words and twenty five letters

Good to have a hobby.