This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A371510 #17 Mar 26 2024 13:19:06 %S A371510 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, %T A371510 30,29,27,3,20,11,32,18,23,12,28,27,25,0,15,7,25,11,17,8,22,20,21,1, %U A371510 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 %N A371510 Number of swaps needed to bubble-sort the US English name of n. %C A371510 No swaps involve hyphens or spaces. %H A371510 Eric Angelini and Nicolas Graner, <a href="https://cinquantesignes.blogspot.com/2024/03/more-bubble-sorting.html">More bubble sorting</a>, personal blog, March 2024. %H A371510 Hans Havermann, <a href="/A371510/a371510.png">Graph of terms to one million</a> %e A371510 For n=0, "zero" requires a(0) = 4 swaps of adjacent letters to reach ascending alphabetical order: ZERO-->EZRO-EZOR-EOZR-EORZ. %o A371510 (Python) %o A371510 from num2words import num2words %o A371510 def a(n): %o A371510 s = [c for c in num2words(n).replace(" and", "") if c.isalpha()] %o A371510 L, c, swap = list(s), 0, True %o A371510 while swap: %o A371510 swap = False %o A371510 for i in range(len(L)-1): %o A371510 if L[i] > L[i+1]: %o A371510 L[i], L[i+1], c, swap = L[i+1], L[i], c+1, True %o A371510 return c %o A371510 print([a(n) for n in range(101)]) # _Michael S. Branicky_, Mar 25 2024 %Y A371510 Cf. A371478 (fixed points). %K A371510 base,nonn,word %O A371510 0,1 %A A371510 _Eric Angelini_ and Nicolas Graner, Mar 25 2024