-
-
Save valtron/d8218522b6840ddfafa56ff75e2bb487 to your computer and use it in GitHub Desktop.
Aaronson's Sentence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Aaronson's Sentence | |
# https://oeis.org/A005224 | |
import re | |
import collections | |
from num2words import num2words | |
l = 1 | |
q = collections.deque() | |
def emit(txt): | |
global l | |
print(txt, end = '') | |
for c in re.sub('\W+', '', txt.lower()): | |
if c == 't': | |
q.append(l) | |
l += 1 | |
emit("T is the ") | |
while q: | |
i = q.popleft() | |
emit(num2words(i, ordinal = True) + ", ") | |
print("letter in this sentence.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment