OFFSET
0,1
COMMENTS
No swaps involve hyphens or spaces.
LINKS
Eric Angelini and Nicolas Graner, More bubble sorting, personal blog, March 2024.
Hans Havermann, Graph of terms to one million
EXAMPLE
For n=0, "zero" requires a(0) = 4 swaps of adjacent letters to reach ascending alphabetical order: ZERO-->EZRO-EZOR-EOZR-EORZ.
PROG
(Python)
from num2words import num2words
def a(n):
s = [c for c in num2words(n).replace(" and", "") if c.isalpha()]
L, c, swap = list(s), 0, True
while swap:
swap = False
for i in range(len(L)-1):
if L[i] > L[i+1]:
L[i], L[i+1], c, swap = L[i+1], L[i], c+1, True
return c
print([a(n) for n in range(101)]) # Michael S. Branicky, Mar 25 2024
CROSSREFS
KEYWORD
base,nonn,word
AUTHOR
Eric Angelini and Nicolas Graner, Mar 25 2024
STATUS
approved