cp's OEIS Frontend

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.

Showing 1-1 of 1 results.

A371510 Number of swaps needed to bubble-sort the US English name of n.

Original entry on oeis.org

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
Offset: 0

Views

Author

Eric Angelini and Nicolas Graner, Mar 25 2024

Keywords

Comments

No swaps involve hyphens or spaces.

Examples

			For n=0, "zero" requires a(0) = 4 swaps of adjacent letters to reach ascending alphabetical order: ZERO-->EZRO-EZOR-EOZR-EORZ.
		

Crossrefs

Cf. A371478 (fixed points).

Programs

  • 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
Showing 1-1 of 1 results.