Skip to content

Instantly share code, notes, and snippets.

@valtron
Last active April 1, 2017 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valtron/d8218522b6840ddfafa56ff75e2bb487 to your computer and use it in GitHub Desktop.
Save valtron/d8218522b6840ddfafa56ff75e2bb487 to your computer and use it in GitHub Desktop.
Aaronson's Sentence
# 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