|
|
A371510
|
|
Number of swaps needed to bubble-sort the US English name of n.
|
|
1
|
|
|
4, 3, 2, 8, 1, 3, 1, 5, 2, 4, 2, 4, 9, 16, 16, 10, 13, 17, 11, 13, 5, 21, 14, 34, 21, 25, 16, 30, 29, 27, 3, 20, 11, 32, 18, 23, 12, 28, 27, 25, 0, 15, 7, 25, 11, 17, 8, 22, 20, 21, 1, 13, 7, 25, 10, 15, 7, 21, 17, 16, 2, 18, 12, 31, 18, 21, 11, 26, 25, 23, 6, 22, 15, 35, 22, 25, 16, 29, 30, 28, 2, 14, 8, 26, 13, 18, 8, 22, 19, 17, 4, 16, 10, 30, 15, 22, 12, 24, 26, 21, 28
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,1
|
|
COMMENTS
|
No swaps involve hyphens or spaces.
|
|
LINKS
|
|
|
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
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,nonn,word
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|